mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from libpng-1.4.0beta36.tar
This commit is contained in:
23
pngrutil.c
23
pngrutil.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.4.0 [October 6, 2008]
|
||||
* Last changed in libpng 1.4.0 [October 26, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -1959,21 +1959,26 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
}
|
||||
#endif
|
||||
|
||||
key = (png_charp)png_malloc_warn(png_ptr, length + 1);
|
||||
if (key == NULL)
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
|
||||
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
|
||||
if (png_ptr->chunkdata == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "No memory to process text chunk");
|
||||
return;
|
||||
}
|
||||
slength = (png_size_t)length;
|
||||
png_crc_read(png_ptr, (png_bytep)key, slength);
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
|
||||
|
||||
if (png_crc_finish(png_ptr, skip))
|
||||
{
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
key = png_ptr->chunkdata;
|
||||
|
||||
key[slength] = 0x00;
|
||||
|
||||
for (text = key; *text; text++)
|
||||
@@ -1987,7 +1992,8 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (text_ptr == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Not enough memory to process text chunk");
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
return;
|
||||
}
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
@@ -2002,7 +2008,8 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
png_free(png_ptr, text_ptr);
|
||||
if (ret)
|
||||
png_warning(png_ptr, "Insufficient memory to process text chunk");
|
||||
@@ -2056,7 +2063,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
}
|
||||
#endif
|
||||
|
||||
png_free(png_ptr,png_ptr->chunkdata);
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
|
||||
if (png_ptr->chunkdata == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user