Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1363)

Side by Side Diff: src/core/SkStream.cpp

Issue 1374493002: SkStream: don't segfault on empty asset getMemoryBase(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/StreamTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkStream.h" 10 #include "SkStream.h"
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 that->fOffset = this->fOffset; 788 that->fOffset = this->fOffset;
789 that->fCurrentOffset = this->fCurrentOffset; 789 that->fCurrentOffset = this->fCurrentOffset;
790 return that.detach(); 790 return that.detach();
791 } 791 }
792 792
793 size_t getLength() const override { 793 size_t getLength() const override {
794 return fSize; 794 return fSize;
795 } 795 }
796 796
797 const void* getMemoryBase() override { 797 const void* getMemoryBase() override {
798 if (nullptr == fBlockMemory->fHead->fNext) { 798 if (nullptr != fBlockMemory->fHead &&
799 nullptr == fBlockMemory->fHead->fNext) {
799 return fBlockMemory->fHead->start(); 800 return fBlockMemory->fHead->start();
800 } 801 }
801 return nullptr; 802 return nullptr;
802 } 803 }
803 804
804 private: 805 private:
805 SkAutoTUnref<SkBlockMemoryRefCnt> const fBlockMemory; 806 SkAutoTUnref<SkBlockMemoryRefCnt> const fBlockMemory;
806 SkDynamicMemoryWStream::Block const * fCurrent; 807 SkDynamicMemoryWStream::Block const * fCurrent;
807 size_t const fSize; 808 size_t const fSize;
808 size_t fOffset; 809 size_t fOffset;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 while (true) { 967 while (true) {
967 count = input->read(scratch, sizeof(scratch)); 968 count = input->read(scratch, sizeof(scratch));
968 if (0 == count) { 969 if (0 == count) {
969 return true; 970 return true;
970 } 971 }
971 if (!out->write(scratch, count)) { 972 if (!out->write(scratch, count)) {
972 return false; 973 return false;
973 } 974 }
974 } 975 }
975 } 976 }
OLDNEW
« no previous file with comments | « no previous file | tests/StreamTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698