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

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: 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..53ab8e346d3f9b90a434570e4d118fe0e0c11687 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1909,6 +1909,18 @@ 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;
+ }
+
+ if (!buffer.isValid()) {
+ // If the buffer is not valid, pathRef should be nullptr.
reed1 2016/01/13 20:27:11 why are we throwing, instead of just returning, as
ajuma 2016/01/13 20:47:54 Looking at where this originated (https://coderevi
reed1 2016/01/13 21:05:47 Lets not add code in places that can never be reac
ajuma 2016/01/13 21:11:41 Removed the check.
+ sk_throw();
+ }
+
+ fPathRef.reset(pathRef);
+ SkDEBUGCODE(this->validate();)
+ buffer.skipToAlign4();
// compatibility check
if (version < kPathPrivFirstDirection_Version) {
@@ -1929,17 +1941,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