aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-01-21 06:44:18 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-21 06:44:18 -0800
commitb0d25466be6106a0084a4d76c6f79efe389ba820 (patch)
tree3116a4beaf6dd67764e0d9a7f7a0d3eee60e7175 /src
parentdfe3e5052260e087d32326976183b58c36694ffd (diff)
detect bad/corrupt flattenable factory indices
Diffstat (limited to 'src')
-rw-r--r--src/core/SkReadBuffer.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 06aa9cb6a9..ca89022d12 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -340,7 +340,10 @@ SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) {
return nullptr; // writer failed to give us the flattenable
}
index -= 1; // we stored the index-base-1
- SkASSERT(index < fFactoryCount);
+ if ((unsigned)index >= (unsigned)fFactoryCount) {
+ this->validate(false);
+ return nullptr;
+ }
factory = fFactoryArray[index];
} else if (fFactoryTDArray) {
int32_t index = fReader.readU32();
@@ -348,6 +351,10 @@ SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) {
return nullptr; // writer failed to give us the flattenable
}
index -= 1; // we stored the index-base-1
+ if ((unsigned)index >= (unsigned)fFactoryCount) {
+ this->validate(false);
+ return nullptr;
+ }
factory = (*fFactoryTDArray)[index];
} else {
factory = (SkFlattenable::Factory)readFunctionPtr();
@@ -366,8 +373,8 @@ SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) {
// check that we read the amount we expected
size_t sizeRead = fReader.offset() - offset;
if (sizeRecorded != sizeRead) {
- // we could try to fix up the offset...
- sk_throw();
+ this->validate(false);
+ return nullptr;
}
} else {
// we must skip the remaining data