From 1b29ad289e8177cfc831e2975046852b475fd6b1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 10 Jul 2016 18:33:19 +0200 Subject: [PATCH] PNG translator: fix gcc2 complaining about setjmp clobbering variables. Fixes #12662. --- src/add-ons/translators/png/PNGTranslator.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/add-ons/translators/png/PNGTranslator.cpp b/src/add-ons/translators/png/PNGTranslator.cpp index a982ad3e29..cc93fb5b8d 100644 --- a/src/add-ons/translators/png/PNGTranslator.cpp +++ b/src/add-ons/translators/png/PNGTranslator.cpp @@ -292,6 +292,18 @@ PNGTranslator::DerivedIdentify(BPositionIO *inSource, return identify_png_header(inSource, outInfo); } + +// Workaround for gcc2 complaining about clobbered variables when we do a +// setjmp, even though the variables are not accessed when returning from +// a longjmp. Moving setjmp to a different function is enough to hide the +// problem from gcc2. +static int +setjmp_wrapper(jmp_buf buf) +{ + return setjmp(buf); +} + + status_t PNGTranslator::translate_from_png_to_bits(BPositionIO *inSource, BPositionIO *outDestination) @@ -322,7 +334,7 @@ PNGTranslator::translate_from_png_to_bits(BPositionIO *inSource, if (!pinfo) break; // set error handling - if (setjmp(png_jmpbuf(ppng))) + if (setjmp_wrapper(png_jmpbuf(ppng))) // When an error occurs in libpng, it uses // the longjmp function to continue execution // from this point @@ -829,7 +841,7 @@ PNGTranslator::translate_from_bits_to_png(BPositionIO *inSource, break; } // set error handling - if (setjmp(png_jmpbuf(ppng))) { + if (setjmp_wrapper(png_jmpbuf(ppng))) { // When an error occurs in libpng, it uses // the longjmp function to continue execution // from this point