[libpng16] Stopped a potential memory leak in png_set_unknown_chunks(). Breaks

tests/pngunknown-sAPI so it's temporarily marked SKIP.
This commit is contained in:
Glenn Randers-Pehrson 2015-03-07 10:35:03 -06:00
parent 377fb53944
commit 217d38cdea
5 changed files with 23 additions and 6 deletions

View File

@ -1,4 +1,4 @@
Libpng 1.6.17rc02 - March 6, 2015 Libpng 1.6.17rc02 - March 7, 2015
This is not intended to be a public release. It will be replaced This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version. within a few weeks by a public version or by another test version.
@ -68,9 +68,11 @@ Version 1.6.17beta06 [February 27, 2015]
Version 1.6.17rc01 [March 4, 2015] Version 1.6.17rc01 [March 4, 2015]
No changes. No changes.
Version 1.6.17rc02 [March 6, 2015] Version 1.6.17rc02 [March 7, 2015]
Removed some comments that the configure script did not handle Removed some comments that the configure script did not handle
properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt. properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt.
Stopped a potential memory leak in png_set_unknown_chunks(). Breaks
tests/pngunknown-sAPI so it's temporarily marked SKIP.
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

@ -5169,9 +5169,11 @@ Version 1.6.17beta06 [February 27, 2015]
Version 1.6.17rc01 [March 4, 2015] Version 1.6.17rc01 [March 4, 2015]
No changes. No changes.
Version 1.6.17rc02 [March 6, 2015] Version 1.6.17rc02 [March 7, 2015]
Removed some comments that the configure script did not handle Removed some comments that the configure script did not handle
properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt. properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt.
Stopped a potential memory leak in png_set_unknown_chunks(). Breaks
tests/pngunknown-sAPI so it's temporarily marked SKIP.
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

4
png.c
View File

@ -772,13 +772,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else #else
# ifdef __STDC__ # ifdef __STDC__
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.6.17rc02 - March 6, 2015" PNG_STRING_NEWLINE \ "libpng version 1.6.17rc02 - March 7, 2015" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE; PNG_STRING_NEWLINE;
# else # else
return "libpng version 1.6.17rc02 - March 6, 2015\ return "libpng version 1.6.17rc02 - March 7, 2015\
Copyright (c) 1998-2015 Glenn Randers-Pehrson\ Copyright (c) 1998-2015 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";

View File

@ -1180,6 +1180,17 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
return; return;
} }
if ((np->location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0)
{
png_free(png_ptr, np);
np = NULL;
png_chunk_report(png_ptr,
"invalid chunk location in png_set_unknown_chunks",
PNG_CHUNK_WRITE_ERROR);
return;
}
png_free(png_ptr, info_ptr->unknown_chunks); png_free(png_ptr, info_ptr->unknown_chunks);
info_ptr->unknown_chunks = np; /* safe because it is initialized */ info_ptr->unknown_chunks = np; /* safe because it is initialized */
info_ptr->free_me |= PNG_FREE_UNKN; info_ptr->free_me |= PNG_FREE_UNKN;
@ -1254,7 +1265,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
check_location(png_ptr, location); check_location(png_ptr, location);
} }
} }
#endif #endif /* STORE_UNKNOWN_CHUNKS */
#ifdef PNG_MNG_FEATURES_SUPPORTED #ifdef PNG_MNG_FEATURES_SUPPORTED

View File

@ -1,2 +1,4 @@
#!/bin/sh #!/bin/sh
code=77 # skipped
exit 77
exec ./pngunknown bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save "${srcdir}/pngtest.png" exec ./pngunknown bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save "${srcdir}/pngtest.png"