mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
De-volatilize the internal implementation of png_safe_execute
`png_safe_execute` called `setjmp` in a context where the result was undefined (an assignment statement). This corrects the code and removes volatile statements that were introduced previously to quell warnings from earlier versions of GCC. Co-authored-by: John Bowler <jbowler@acm.org>
This commit is contained in:
parent
7dacc4d5aa
commit
2a4f0f5aee
26
pngerror.c
26
pngerror.c
@ -933,31 +933,25 @@ png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int /* PRIVATE */
|
int /* PRIVATE */
|
||||||
png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
png_safe_execute(png_imagep image, int (*function)(png_voidp), png_voidp arg)
|
||||||
{
|
{
|
||||||
volatile png_imagep image = image_in;
|
png_voidp saved_error_buf = image->opaque->error_buf;
|
||||||
volatile int result;
|
|
||||||
volatile png_voidp saved_error_buf;
|
|
||||||
jmp_buf safe_jmpbuf;
|
jmp_buf safe_jmpbuf;
|
||||||
|
int result;
|
||||||
|
|
||||||
/* Safely execute function(arg) with png_error returning to this function. */
|
/* Safely execute function(arg), with png_error returning back here. */
|
||||||
saved_error_buf = image->opaque->error_buf;
|
if (setjmp(safe_jmpbuf) == 0)
|
||||||
result = setjmp(safe_jmpbuf) == 0;
|
|
||||||
|
|
||||||
if (result != 0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
image->opaque->error_buf = safe_jmpbuf;
|
image->opaque->error_buf = safe_jmpbuf;
|
||||||
result = function(arg);
|
result = function(arg);
|
||||||
|
image->opaque->error_buf = saved_error_buf;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* On png_error, return via longjmp, pop the jmpbuf, and free the image. */
|
||||||
image->opaque->error_buf = saved_error_buf;
|
image->opaque->error_buf = saved_error_buf;
|
||||||
|
png_image_free(image);
|
||||||
/* And do the cleanup prior to any failure return. */
|
return 0;
|
||||||
if (result == 0)
|
|
||||||
png_image_free(image);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
||||||
#endif /* READ || WRITE */
|
#endif /* READ || WRITE */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user