SkBlockMemoryStream: correct test in getMemoryBase().
The test "nullptr == fBlockMemory->fHead->fNext" tests that all of the data is in one block, but it is also necessary to test "fBlockMemory->fHead" to ensure that there is a first block with data in it. Review URL: https://codereview.chromium.org/1374493002
This commit is contained in:
parent
f1b7a1d828
commit
209c1624ad
@ -795,7 +795,8 @@ public:
|
||||
}
|
||||
|
||||
const void* getMemoryBase() override {
|
||||
if (nullptr == fBlockMemory->fHead->fNext) {
|
||||
if (nullptr != fBlockMemory->fHead &&
|
||||
nullptr == fBlockMemory->fHead->fNext) {
|
||||
return fBlockMemory->fHead->start();
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -391,5 +391,11 @@ DEF_TEST(StreamCopy, reporter) {
|
||||
stream_copy_test(reporter, src, N, &dumbStream);
|
||||
SkMemoryStream smartStream(src.get(), (size_t)N);
|
||||
stream_copy_test(reporter, src, N, &smartStream);
|
||||
|
||||
}
|
||||
|
||||
DEF_TEST(StreamEmptyStreamMemoryBase, r) {
|
||||
SkDynamicMemoryWStream tmp;
|
||||
SkAutoTDelete<SkStreamAsset> asset(tmp.detachAsStream());
|
||||
REPORTER_ASSERT(r, nullptr == asset->getMemoryBase());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user