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

Unified Diff: src/core/SkPictureData.h

Issue 1893423002: Fix ImageFilter fuzzer issue (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Switch SkReader32 to SkReadBuffer Created 4 years, 8 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 | src/core/SkPicturePlayback.h » ('j') | src/core/SkPicturePlayback.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureData.h
diff --git a/src/core/SkPictureData.h b/src/core/SkPictureData.h
index 3acaf579bc8e5200fda3a99ece271783faea2b8d..b6c4ce43da7d439d5a01aa77c7909f3f7d459124 100644
--- a/src/core/SkPictureData.h
+++ b/src/core/SkPictureData.h
@@ -87,39 +87,58 @@ protected:
bool parseBuffer(SkReadBuffer& buffer);
public:
- const SkBitmap& getBitmap(SkReader32* reader) const {
+ const SkBitmap& getBitmap(SkReadBuffer* reader) const {
const int index = reader->readInt();
+ if (index < 0 || index >= fBitmaps.count()) {
reed1 2016/04/19 12:54:11 Seems fine, but a little repetitive. One condensa
robertphillips 2016/04/19 14:34:42 Done.
+ reader->makeInvalid();
+ return fEmptyBitmap;
+ }
return fBitmaps[index];
}
- const SkImage* getImage(SkReader32* reader) const {
+ const SkImage* getImage(SkReadBuffer* reader) const {
const int index = reader->readInt();
+ if (index < 0 || index >= fImageCount) {
+ reader->makeInvalid();
+ return nullptr;
+ }
return fImageRefs[index];
}
- const SkPath& getPath(SkReader32* reader) const {
- int index = reader->readInt() - 1;
+ const SkPath& getPath(SkReadBuffer* reader) const {
+ const int index = reader->readInt() - 1;
+ if (index < 0 || index >= fPaths.count()) {
+ reader->makeInvalid();
+ return fEmptyPath;
+ }
return fPaths[index];
}
- const SkPicture* getPicture(SkReader32* reader) const {
- int index = reader->readInt();
- SkASSERT(index > 0 && index <= fPictureCount);
- return fPictureRefs[index - 1];
+ const SkPicture* getPicture(SkReadBuffer* reader) const {
+ const int index = reader->readInt() - 1;
+ if (index < 0 || index >= fPictureCount) {
+ reader->makeInvalid();
+ return nullptr;
+ }
+ return fPictureRefs[index];
}
- const SkPaint* getPaint(SkReader32* reader) const {
- int index = reader->readInt();
- if (index == 0) {
+ const SkPaint* getPaint(SkReadBuffer* reader) const {
+ const int index = reader->readInt() - 1;
+ if (index < 0 || index >= fPaints.count()) {
+ reader->makeInvalid();
return nullptr;
}
- return &fPaints[index - 1];
+ return &fPaints[index];
}
- const SkTextBlob* getTextBlob(SkReader32* reader) const {
- int index = reader->readInt();
- SkASSERT(index > 0 && index <= fTextBlobCount);
- return fTextBlobRefs[index - 1];
+ const SkTextBlob* getTextBlob(SkReadBuffer* reader) const {
+ const int index = reader->readInt() - 1;
+ if (index < 0 || index >= fTextBlobCount) {
+ reader->makeInvalid();
+ return nullptr;
+ }
+ return fTextBlobRefs[index];
}
#if SK_SUPPORT_GPU
@@ -160,6 +179,9 @@ private:
sk_sp<SkData> fOpData; // opcodes and parameters
+ const SkPath fEmptyPath;
+ const SkBitmap fEmptyBitmap;
+
const SkPicture** fPictureRefs;
int fPictureCount;
const SkTextBlob** fTextBlobRefs;
« no previous file with comments | « no previous file | src/core/SkPicturePlayback.h » ('j') | src/core/SkPicturePlayback.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698