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

Unified Diff: include/core/SkFlattenableBuffers.h

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
« no previous file with comments | « no previous file | samplecode/SampleFilterFuzz.cpp » ('j') | src/core/SkColorTable.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkFlattenableBuffers.h
diff --git a/include/core/SkFlattenableBuffers.h b/include/core/SkFlattenableBuffers.h
index 00cb77a8d35f1ba98e80493767c081764f4d51d0..aa61f21a7b2d57ac0c14848cfa37e8aaec7d5b35 100644
--- a/include/core/SkFlattenableBuffers.h
+++ b/include/core/SkFlattenableBuffers.h
@@ -139,8 +139,13 @@ public:
SkData* readByteArrayAsData() {
size_t len = this->getArrayCount();
- void* buffer = sk_malloc_throw(len);
- (void)this->readByteArray(buffer, len);
+ void* buffer = NULL;
+ if (this->validateAvailable(len)) {
+ buffer = sk_malloc_throw(len);
+ (void)this->readByteArray(buffer, len);
+ } else {
+ len = 0;
+ }
return SkData::NewFromMalloc(buffer, len);
}
@@ -160,6 +165,14 @@ public:
*/
virtual bool isValid() const { return true; }
+ /** This function returns true by default
+ * If isValidating() is true, it will return whether there's
+ * at least "size" memory left to read in the stream.
+ *
+ * @param size amount of memory that should still be available
+ */
+ virtual bool validateAvailable(size_t size) { return true; }
+
private:
template <typename T> T* readFlattenableT();
uint32_t fFlags;
« no previous file with comments | « no previous file | samplecode/SampleFilterFuzz.cpp » ('j') | src/core/SkColorTable.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698