Imported from libpng-1.4.0beta36.tar
diff --git a/pngrutil.c b/pngrutil.c
index 471911d..5987709 100644
--- a/pngrutil.c
+++ b/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 @@
}
#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 @@
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 @@
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 @@
}
#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)
{