- allow zero length PLTE chunks (fixes GraphicsMagick testsuite) OBS-URL: https://build.opensuse.org/request/show/159787 OBS-URL: https://build.opensuse.org/package/show/graphics/libpng16?expand=0&rev=21
58 lines
2.1 KiB
Diff
58 lines
2.1 KiB
Diff
http://sourceforge.net/mailarchive/forum.php?thread_name=20130219075910.GK27522%40danbala.tuwien.ac.at&forum_name=png-mng-implement
|
|
|
|
From 9ee585718b346d32767015152a728106922b49d1 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <9ee585718b346d32767015152a728106922b49d1.1361241956.git.jbowler@acm.org>
|
|
From: John Bowler <jbowler@acm.org>
|
|
Date: Mon, 18 Feb 2013 18:44:14 -0800
|
|
Subject: [libpng16] Reenable code to allow zero length PLTE chunks for MNG
|
|
support.
|
|
|
|
Signed-off-by: John Bowler <jbowler@acm.org>
|
|
---
|
|
pngset.c | 16 ++++++++++++++--
|
|
1 file changed, 14 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/pngset.c b/pngset.c
|
|
index ac39a44..f89861e 100644
|
|
--- a/pngset.c
|
|
+++ b/pngset.c
|
|
@@ -514,7 +514,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|
|
|
png_debug1(1, "in %s storage function", "PLTE");
|
|
|
|
- if (png_ptr == NULL || info_ptr == NULL || palette == NULL)
|
|
+ if (png_ptr == NULL || info_ptr == NULL)
|
|
return;
|
|
|
|
if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
|
|
@@ -529,6 +529,17 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|
}
|
|
}
|
|
|
|
+ if ((num_palette > 0 && palette == NULL) ||
|
|
+ (num_palette == 0
|
|
+# ifdef PNG_MNG_FEATURES_SUPPORTED
|
|
+ && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0
|
|
+# endif
|
|
+ ))
|
|
+ {
|
|
+ png_chunk_report(png_ptr, "Invalid palette", PNG_CHUNK_ERROR);
|
|
+ return;
|
|
+ }
|
|
+
|
|
/* It may not actually be necessary to set png_ptr->palette here;
|
|
* we do it for backward compatibility with the way the png_handle_tRNS
|
|
* function used to do the allocation.
|
|
@@ -545,7 +556,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
|
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
|
|
|
- memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
|
+ if (num_palette > 0)
|
|
+ memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
|
info_ptr->palette = png_ptr->palette;
|
|
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
|
|
|
--
|
|
1.8.1.2
|