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

Unified Diff: src/core/SkRegionPriv.h

Issue 1143603003: Prevent integer wrap around for malloc size when creating a SkRegion (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify Created 5 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRegionPriv.h
diff --git a/src/core/SkRegionPriv.h b/src/core/SkRegionPriv.h
index c8f000df35e6eeb0c7b98b04adf9f29d2294532e..00feedeab80587fe00ae6c208020bf62937c2b11 100644
--- a/src/core/SkRegionPriv.h
+++ b/src/core/SkRegionPriv.h
@@ -65,7 +65,10 @@ public:
SkASSERT(count >= SkRegion::kRectRegionRuns);
- RunHead* head = (RunHead*)sk_malloc_throw(sizeof(RunHead) + count * sizeof(RunType));
+ const int64_t size = sk_64_mul(count, sizeof(RunType)) + sizeof(RunHead);
+ if (count < 0 || !sk_64_isS32(size)) { SK_CRASH(); }
+
+ RunHead* head = (RunHead*)sk_malloc_throw(size);
head->fRefCnt = 1;
head->fRunCount = count;
// these must be filled in later, otherwise we will be invalid
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698