summaryrefslogtreecommitdiff
path: root/pngset.c
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp@shaggy.simplesystems.org>2012-03-17 00:21:45 -0500
committerGlenn Randers-Pehrson <glennrp@shaggy.simplesystems.org>2012-03-17 00:21:45 -0500
commitf5dcba6b9bcd0495c544daea73e64bebfbe08faf (patch)
treeae25b49c69ee609ef08a4e8ad5048487822cfc8e /pngset.c
parentc26d6e9aac5681aa00024d223cc0033f6dbb3a2d (diff)
downloadlibpng-f5dcba6b9bcd0495c544daea73e64bebfbe08faf.tar.gz
[libpng16] Never mind, undid previous change.
Diffstat (limited to 'pngset.c')
-rw-r--r--pngset.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/pngset.c b/pngset.c
index 6b74d945b..bde866f89 100644
--- a/pngset.c
+++ b/pngset.c
@@ -706,28 +706,24 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
*/
if (info_ptr->num_text + num_text > info_ptr->max_text)
{
- int old_max_text = info_ptr->max_text;
- int old_num_text = info_ptr->num_text;
-
if (info_ptr->text != NULL)
{
png_textp old_text;
+ int old_max;
+ old_max = info_ptr->max_text;
info_ptr->max_text = info_ptr->num_text + num_text + 8;
old_text = info_ptr->text;
-
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
if (info_ptr->text == NULL)
{
- /* Restore to previous condition */
- info_ptr->max_text = old_max_text;
- info_ptr->text = old_text;
+ png_free(png_ptr, old_text);
return(1);
}
- png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text *
+ png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
png_sizeof(png_text)));
png_free(png_ptr, old_text);
}
@@ -739,12 +735,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
if (info_ptr->text == NULL)
- {
- /* Restore to previous condition */
- info_ptr->num_text = old_num_text;
- info_ptr->max_text = old_max_text;
return(1);
- }
info_ptr->free_me |= PNG_FREE_TEXT;
}