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

Unified Diff: src/core/SkPath.cpp

Issue 1589533002: Fix fuzzer-found deserialization bugs (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Fix build error by using explicit cast Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/core/SkPathRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPath.cpp
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index ab8d7359d2271b5a15b531859f44379522a4b378..4af2dad5262c97fa15e1717eabd93debfeaa718f 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1909,6 +1909,13 @@ size_t SkPath::readFromMemory(const void* storage, size_t length) {
uint8_t dir = (packed >> kDirection_SerializationShift) & 0x3;
fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1;
SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer);
+ if (!pathRef) {
+ return 0;
+ }
+
+ fPathRef.reset(pathRef);
+ SkDEBUGCODE(this->validate();)
+ buffer.skipToAlign4();
// compatibility check
if (version < kPathPrivFirstDirection_Version) {
@@ -1929,17 +1936,7 @@ size_t SkPath::readFromMemory(const void* storage, size_t length) {
fFirstDirection = dir;
}
- size_t sizeRead = 0;
- if (buffer.isValid()) {
- fPathRef.reset(pathRef);
- SkDEBUGCODE(this->validate();)
- buffer.skipToAlign4();
- sizeRead = buffer.pos();
- } else if (pathRef) {
- // If the buffer is not valid, pathRef should be nullptr
- sk_throw();
- }
- return sizeRead;
+ return buffer.pos();
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/core/SkPathRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698