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

Unified Diff: src/core/SkPixelRef.cpp

Issue 112783004: ensure that we call onUnlock only when we 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 | « include/core/SkPixelRef.h ('k') | src/core/SkScaledImageCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPixelRef.cpp
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index b5daf0b57a90ca0321babf11c37da2eef05fab93..740d269a27a339065b4a91c9f8fa8fbb4d80ca94 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -178,6 +178,10 @@ void SkPixelRef::lockPixels() {
if (1 == ++fLockCount) {
fPixels = this->onLockPixels(&fColorTable);
+ // If onLockPixels failed, it will return NULL
+ if (NULL == fPixels) {
+ fColorTable = NULL;
+ }
}
}
}
@@ -190,9 +194,14 @@ void SkPixelRef::unlockPixels() {
SkASSERT(fLockCount > 0);
if (0 == --fLockCount) {
- this->onUnlockPixels();
- fPixels = NULL;
- fColorTable = NULL;
+ // don't call onUnlockPixels unless onLockPixels succeeded
+ if (fPixels) {
+ this->onUnlockPixels();
+ fPixels = NULL;
+ fColorTable = NULL;
+ } else {
+ SkASSERT(NULL == fColorTable);
+ }
}
}
}
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/core/SkScaledImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698