[libpng17] Avoid dereferencing NULL pointer possibly returned from

png_create_write_struct() (Andrew Church).
This commit is contained in:
Glenn Randers-Pehrson 2013-04-29 08:58:15 -05:00
parent cf76fe8654
commit 7073d26e51
3 changed files with 37 additions and 33 deletions

View File

@ -272,6 +272,8 @@ Version 1.7.0beta12 [April 29, 2013]
Added png_app_warning for out-of-range unknown chunk index in Added png_app_warning for out-of-range unknown chunk index in
png_set_unknown_chunk_location(). png_set_unknown_chunk_location().
Expanded manual paragraph about writing private chunks. Expanded manual paragraph about writing private chunks.
Avoid dereferencing NULL pointer possibly returned from
png_create_write_struct() (Andrew Church).
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

View File

@ -4560,6 +4560,8 @@ Version 1.7.0beta12 [April 29, 2013]
Added png_app_warning for out-of-range unknown chunk index in Added png_app_warning for out-of-range unknown chunk index in
png_set_unknown_chunk_location(). png_set_unknown_chunk_location().
Expanded manual paragraph about writing private chunks. Expanded manual paragraph about writing private chunks.
Avoid dereferencing NULL pointer possibly returned from
png_create_write_struct() (Andrew Church).
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

View File

@ -500,50 +500,50 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
/* Set the zlib control values to defaults; they can be overridden by the if (png_ptr != NULL)
* application after the struct has been created. {
*/ /* Set the zlib control values to defaults; they can be overridden by the
png_ptr->zbuffer_size = PNG_ZBUF_SIZE; * application after the struct has been created.
*/
png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
/* The 'zlib_strategy' setting is irrelevant because png_default_claim in /* The 'zlib_strategy' setting is irrelevant because png_default_claim in
* pngwutil.c defaults it according to whether or not filters will be used, * pngwutil.c defaults it according to whether or not filters will be
* and ignores this setting. * used, and ignores this setting.
*/ */
png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY; png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;
png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION; png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;
png_ptr->zlib_mem_level = 8; png_ptr->zlib_mem_level = 8;
png_ptr->zlib_window_bits = 15; png_ptr->zlib_window_bits = 15;
png_ptr->zlib_method = 8; png_ptr->zlib_method = 8;
#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED #ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY; png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;
png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION; png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;
png_ptr->zlib_text_mem_level = 8; png_ptr->zlib_text_mem_level = 8;
png_ptr->zlib_text_window_bits = 15; png_ptr->zlib_text_window_bits = 15;
png_ptr->zlib_text_method = 8; png_ptr->zlib_text_method = 8;
#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */ #endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
/* This is a highly dubious configuration option; by default it is off, but /* This is a highly dubious configuration option; by default it is off,
* it may be appropriate for private builds that are testing extensions not * but it may be appropriate for private builds that are testing
* conformant to the current specification, or of applications that must not * extensions not conformant to the current specification, or of
* fail to write at all costs! * applications that must not fail to write at all costs!
*/ */
# ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED #ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
/* In stable builds only warn if an application error can be completely /* In stable builds only warn if an application error can be completely
* handled. * handled.
*/ */
# endif #endif
/* App warnings are warnings in release (or release candidate) builds but /* App warnings are warnings in release (or release candidate) builds but
* are errors during development. * are errors during development.
*/ */
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC #if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
# endif #endif
if (png_ptr != NULL)
{
/* TODO: delay this, it can be done in png_init_io() (if the app doesn't /* TODO: delay this, it can be done in png_init_io() (if the app doesn't
* do it itself) avoiding setting the default function if it is not * do it itself) avoiding setting the default function if it is not
* required. * required.