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, |