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

Unified Diff: src/images/SkImageDecoder_libpng.cpp

Issue 951663002: Fix a memory leak when decoding corrupted indexed PNGs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Disable test on platforms that don't use libpng Created 5 years, 9 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
Index: src/images/SkImageDecoder_libpng.cpp
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index f9ef6b7942306016c714668555d96b7c3c31fbb3..c074268cffbc996ef1b0f01765402f806504ba8c 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -362,6 +362,12 @@ SkImageDecoder::Result SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap
SkAutoLockPixels alp(*decodedBitmap);
+ // Repeat setjmp, otherwise variables declared since the last call (e.g. alp
+ // and aur) won't get their destructors called in case of a failure.
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ return kFailure;
+ }
+
/* Turn on interlace handling. REQUIRED if you are not using
* png_read_image(). To see how to handle interlacing passes,
* see the png_read_row() method below:
« no previous file with comments | « gyp/tests.gypi ('k') | tests/InvalidIndexedPngTest.cpp » ('j') | tests/InvalidIndexedPngTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698