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

Unified Diff: src/core/SkColorTable.cpp

Issue 116773002: Fixed more fuzzer issues (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Changed isAvailable for validateAvailable Created 7 years 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
Index: src/core/SkColorTable.cpp
diff --git a/src/core/SkColorTable.cpp b/src/core/SkColorTable.cpp
index c719defe869359af969b7f571ad6a2bb720cb566..12ec43ec98013f9e1f87510ff1714914572c8f52 100644
--- a/src/core/SkColorTable.cpp
+++ b/src/core/SkColorTable.cpp
@@ -90,8 +90,15 @@ SkColorTable::SkColorTable(SkFlattenableReadBuffer& buffer) {
fAlphaType = SkToU8(buffer.readUInt());
fCount = buffer.getArrayCount();
- fColors = (SkPMColor*)sk_malloc_throw(fCount * sizeof(SkPMColor));
- SkDEBUGCODE(bool success =) buffer.readColorArray(fColors, fCount);
+ size_t allocSize = fCount * sizeof(SkPMColor);
+ SkDEBUGCODE(bool success = false;)
+ if (buffer.validateAvailable(allocSize)) {
Stephen White 2013/12/18 00:01:14 Not new to this patch, but I'm really starting to
+ fColors = (SkPMColor*)sk_malloc_throw(allocSize);
+ SkDEBUGCODE(success =) buffer.readColorArray(fColors, fCount);
+ } else {
+ fCount = 0;
+ fColors = NULL;
+ }
#ifdef SK_DEBUG
SkASSERT((unsigned)fCount <= 256);
SkASSERT(success);

Powered by Google App Engine
This is Rietveld 408576698