aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkReadBuffer.cpp
diff options
context:
space:
mode:
authorGravatar Adrienne Walker <enne@chromium.org>2018-06-27 13:04:01 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-28 16:10:57 +0000
commit27300f0d1ae3e237825615a31edbd0c56667f583 (patch)
tree55541d69a6b950f9d7a49042a1621b19d62aa735 /src/core/SkReadBuffer.cpp
parent25e25596566ea199a88b0c22a8707bfe982e48f5 (diff)
Return nullptr from readFlattenable when invalid
Currently, in SkReadBuffer::readFlattenable, if reading the sizeRecorded fails (or any previous read), then the read buffer is invalid and the size returns zero. In this bug, it calls SkLine2DPathEffect::CreateProc which never checks the validity of the readBuffer and returns a valid object. Because the read size also is zero, then unset but seemingly valid object gets returned to the caller. Other failure cases return nullptr when the readBuffer is invalid, so instead of making all procs handle this, just handle this at the end of readFlattenable. It'd be ideal if SkFlattenable::Deserialize could forward this error back to the caller, but this seems like a smaller fix. Bug: chromium: 854947 Change-Id: I26e4e90320c0d2c4efa191d301aa4ac7783eb476 Reviewed-on: https://skia-review.googlesource.com/138000 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/core/SkReadBuffer.cpp')
-rw-r--r--src/core/SkReadBuffer.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 3491428658..7e58e52e67 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -461,6 +461,9 @@ SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) {
// we must skip the remaining data
fReader.skip(sizeRecorded);
}
+ if (!this->isValid()) {
+ return nullptr;
+ }
return obj.release();
}