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

Unified Diff: src/core/SkPictureData.cpp

Issue 1264503011: Double free in ~SkPictureData() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: indent Created 5 years, 5 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/SkPictureData.cpp
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index fc4fdb8230d14655555b8ab35c4d4cf5beb8a2de..4f3ac37066f9197c362d9b0f7b6ac533306d070e 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -373,26 +373,14 @@ bool SkPictureData::parseStreamTag(SkStream* stream,
}
} break;
case SK_PICT_PICTURE_TAG: {
- fPictureCount = size;
- fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount);
- bool success = true;
- int i = 0;
- for ( ; i < fPictureCount; i++) {
+ fPictureCount = 0;
+ fPictureRefs = SkNEW_ARRAY(const SkPicture*, size);
+ for (uint32_t i = 0; i < size; i++) {
fPictureRefs[i] = SkPicture::CreateFromStream(stream, proc);
- if (NULL == fPictureRefs[i]) {
- success = false;
- break;
- }
- }
- if (!success) {
- // Delete all of the pictures that were already created (up to but excluding i):
- for (int j = 0; j < i; j++) {
- fPictureRefs[j]->unref();
+ if (!fPictureRefs[i]) {
+ return false;
}
- // Delete the array
- SkDELETE_ARRAY(fPictureRefs);
- fPictureCount = 0;
- return false;
+ fPictureCount++;
}
} break;
case SK_PICT_BUFFER_SIZE_TAG: {
« 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