提交 f4ea2248 编写于 作者: G Glenn Randers-Pehrson

[devel] Make the 'png_jmpbuf' macro expand to a call that records the correct

    longjmp function as well as returning a pointer to the setjmp
    jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'.
    (John Bowler)
上级 eddc5af8
...@@ -699,6 +699,10 @@ version 1.4.0beta103 [November 21, 2009] ...@@ -699,6 +699,10 @@ version 1.4.0beta103 [November 21, 2009]
after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50 changes above after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50 changes above
and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone needs this and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone needs this
feature but I don't remember who. feature but I don't remember who.
Make the 'png_jmpbuf' macro expand to a call that records the correct
longjmp function as well as returning a pointer to the setjmp
jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'.
(John Bowler)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit
......
...@@ -2386,6 +2386,10 @@ version 1.4.0beta103 [November 21, 2009] ...@@ -2386,6 +2386,10 @@ version 1.4.0beta103 [November 21, 2009]
to png_flush() after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50 to png_flush() after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50
changes above and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone changes above and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone
needs this feature but I don't remember who. needs this feature but I don't remember who.
Make the 'png_jmpbuf' macro expand to a call that records the correct
longjmp function as well as returning a pointer to the setjmp
jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'.
(John Bowler)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit
......
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.4.0beta103 - November 20, 2009 * libpng version 1.4.0beta103 - November 21, 2009
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Authors and maintainers: * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.4.0beta103 - November 20, 2009: Glenn * libpng versions 0.97, January 1998, through 1.4.0beta103 - November 21, 2009: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* *
* libpng versions 1.2.6, August 15, 2004, through 1.4.0beta103, November 20, 2009, are * libpng versions 1.2.6, August 15, 2004, through 1.4.0beta103, November 21, 2009, are
* Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are * Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5 * distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors: * with the following individual added to the list of Contributing Authors:
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
/* Version information for png.h - this should match the version in png.c */ /* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.4.0beta103" #define PNG_LIBPNG_VER_STRING "1.4.0beta103"
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.4.0beta103 - November 20, 2009\n" " libpng version 1.4.0beta103 - November 21, 2009\n"
#define PNG_LIBPNG_VER_SONUM 14 #define PNG_LIBPNG_VER_SONUM 14
#define PNG_LIBPNG_VER_DLLNUM 14 #define PNG_LIBPNG_VER_DLLNUM 14
...@@ -1010,6 +1010,13 @@ typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp ...@@ -1010,6 +1010,13 @@ typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
#endif #endif
#ifdef PNG_SETJMP_SUPPORTED
/* This must match the function definition in <setjmp.h>, and the
* application must include this before png.h to obtain the definition
* of jmp_buf.
*/
typedef void (PNGAPI *png_longjmp_ptr) PNGARG((jmp_buf, int));
#endif
/* Transform masks for the high-level interface */ /* Transform masks for the high-level interface */
#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */
...@@ -1049,7 +1056,8 @@ typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); ...@@ -1049,7 +1056,8 @@ typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
struct png_struct_def struct png_struct_def
{ {
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
jmp_buf jmpbuf; /* used in png_error */ jmp_buf jmpbuf PNG_DEPSTRUCT; /* used in png_error */
png_longjmp_ptr longjmp_fn PNG_DEPSTRUCT;/* setjmp non-local goto function. */
#endif #endif
png_error_ptr error_fn PNG_DEPSTRUCT; /* function for printing errors and aborting */ png_error_ptr error_fn PNG_DEPSTRUCT; /* function for printing errors and aborting */
png_error_ptr warning_fn PNG_DEPSTRUCT; /* function for printing warnings */ png_error_ptr warning_fn PNG_DEPSTRUCT; /* function for printing warnings */
...@@ -1380,6 +1388,26 @@ extern PNG_EXPORT(void,png_set_compression_buffer_size) ...@@ -1380,6 +1388,26 @@ extern PNG_EXPORT(void,png_set_compression_buffer_size)
PNGARG((png_structp png_ptr, png_size_t size)); PNGARG((png_structp png_ptr, png_size_t size));
#endif #endif
/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
* match up.
*/
#ifdef PNG_SETJMP_SUPPORTED
/* This function returns the jmp_buf built in to *png_ptr. It must be
* supplied with an appropriate 'longjmp' function to use on that jmp_buf
* unless the default error function is overridden in which case NULL is
* acceptable. The size of the jmp_buf is checked against the actual size
* allocated by the library - the call will return NULL on a mismatch
* indicating an ABI mismatch.
*/
extern PNG_EXPORT(jmp_buf*, png_set_longjmp_fn)
PNGARG((png_structp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));
# define png_jmpbuf(png_ptr) \
(*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf)))
#else
# define png_jmpbuf(png_ptr) \
(LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
#endif
/* Reset the compression stream */ /* Reset the compression stream */
extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
......
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng version 1.4.0beta103 - November 20, 2009 * libpng version 1.4.0beta103 - November 21, 2009
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
...@@ -1352,13 +1352,6 @@ typedef char FAR * FAR * FAR * png_charppp; ...@@ -1352,13 +1352,6 @@ typedef char FAR * FAR * FAR * png_charppp;
* functions that are passed far data must be model-independent. * functions that are passed far data must be model-independent.
*/ */
#ifdef PNG_SETJMP_SUPPORTED
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#else
# define png_jmpbuf(png_ptr) \
(LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
#endif
/* memory model/platform independent fns */ /* memory model/platform independent fns */
#ifndef PNG_ABORT #ifndef PNG_ABORT
# ifdef _WINDOWS_ # ifdef _WINDOWS_
......
/* pngerror.c - stub functions for i/o and memory allocation /* pngerror.c - stub functions for i/o and memory allocation
* *
* Last changed in libpng 1.4.0 [November 20, 2009] * Last changed in libpng 1.4.0 [November 21, 2009]
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
...@@ -229,6 +229,21 @@ png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message) ...@@ -229,6 +229,21 @@ png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
#endif #endif
#endif /* PNG_READ_SUPPORTED */ #endif /* PNG_READ_SUPPORTED */
#ifdef PNG_SETJMP_SUPPORTED
/* This API only exists if ANSI-C style error handling is used, otherwise
* it is necessary for png_default_error to be overridden.
*/
jmp_buf* PNGAPI
png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)
{
if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf))
return NULL;
png_ptr->longjmp_fn = longjmp_fn;
return &png_ptr->jmpbuf;
}
#endif
/* This is the default error handling function. Note that replacements for /* This is the default error handling function. Note that replacements for
* this function MUST NOT RETURN, or the program will likely crash. This * this function MUST NOT RETURN, or the program will likely crash. This
* function is used by default, or if the program supplies NULL for the * function is used by default, or if the program supplies NULL for the
...@@ -273,16 +288,16 @@ png_default_error(png_structp png_ptr, png_const_charp error_message) ...@@ -273,16 +288,16 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
#endif #endif
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
if (png_ptr) if (png_ptr && png_ptr->longjmp_fn)
{ {
# ifdef USE_FAR_KEYWORD # ifdef USE_FAR_KEYWORD
{ {
jmp_buf jmpbuf; jmp_buf jmpbuf;
png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf)); png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
longjmp(jmpbuf, 1); png_ptr->longjmp_fn(jmpbuf, 1);
} }
# else # else
longjmp(png_ptr->jmpbuf, 1); png_ptr->longjmp_fn(png_ptr->jmpbuf, 1);
# endif # endif
} }
#endif #endif
......
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* Last changed in libpng 1.4.0 [November 20, 2009] * Last changed in libpng 1.4.0 [November 21, 2009]
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
...@@ -78,9 +78,12 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, ...@@ -78,9 +78,12 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf)) if (setjmp(jmpbuf))
#else #else
if (setjmp(png_ptr->jmpbuf)) if (setjmp(png_jmpbuf(png_ptr))) /* Sets longjmp to match setjmp */
#endif #endif
PNG_ABORT(); PNG_ABORT();
#ifdef USE_FAR_KEYWORD
png_memcpy(png_jmpbuf(png_ptr), jmpbuf, png_sizeof(jmp_buf));
#endif
#endif /* PNG_SETJMP_SUPPORTED */ #endif /* PNG_SETJMP_SUPPORTED */
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
......
...@@ -503,7 +503,10 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, ...@@ -503,7 +503,10 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf)) if (setjmp(jmpbuf))
#else #else
if (setjmp(png_ptr->jmpbuf)) if (setjmp(png_jmpbuf(png_ptr))) /* sets longjmp to match setjmp */
#endif
#ifdef USE_FAR_KEYWORD
png_memcpy(png_jmpbuf(png_ptr), jmpbuf, png_sizeof(jmp_buf));
#endif #endif
PNG_ABORT(); PNG_ABORT();
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册