Index: Source/platform/image-decoders/png/PNGImageDecoder.cpp |
diff --git a/Source/platform/image-decoders/png/PNGImageDecoder.cpp b/Source/platform/image-decoders/png/PNGImageDecoder.cpp |
index 86cff4c7c37adf2e9c959417eee6c65c3cd0013a..70b5315e69945a0dcff5a444ec3fceb027f90987 100644 |
--- a/Source/platform/image-decoders/png/PNGImageDecoder.cpp |
+++ b/Source/platform/image-decoders/png/PNGImageDecoder.cpp |
@@ -142,8 +142,11 @@ public: |
PNGImageDecoder* decoder = static_cast<PNGImageDecoder*>(png_get_progressive_ptr(m_png)); |
// We need to do the setjmp here. Otherwise bad things will happen. |
+ // The libpng manual points out: ".. there are some uncertainties about the status of local variables after a longjmp, so the |
+ // user may want to be careful about doing anything after setjmp returns non-zero besides returning itself." This is why |
+ // we avoid referencing |decoder| in the event of an error. |
if (setjmp(JMPBUF(m_png))) |
- return decoder->setFailed(); |
+ return static_cast<PNGImageDecoder*>(png_get_progressive_ptr(m_png))->setFailed(); |
const char* segment; |
while (unsigned segmentLength = data.getSomeData(segment, m_readOffset)) { |