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

Unified Diff: src/lazy/SkDiscardablePixelRef.cpp

Issue 108613005: Ensure we call onUnlock only if onLock succeeded (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | « src/lazy/SkCachingPixelRef.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lazy/SkDiscardablePixelRef.cpp
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index 0b193ade3c35d234fa08b35aacf06e41bcfb4e89..f551436b3b331c89ca389c58ad3012c7618821f1 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -56,14 +56,15 @@ void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
}
void* pixels = fDiscardableMemory->data();
if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) {
- return NULL; // TODO(halcanary) Find out correct thing to do.
+ fDiscardableMemory->unlock();
+ SkDELETE(fDiscardableMemory);
+ fDiscardableMemory = NULL;
+ return NULL;
}
return pixels;
}
void SkDiscardablePixelRef::onUnlockPixels() {
- if (fDiscardableMemory != NULL) {
- fDiscardableMemory->unlock();
- }
+ fDiscardableMemory->unlock();
}
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
« no previous file with comments | « src/lazy/SkCachingPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698