[libpng16] Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
diff --git a/ANNOUNCE b/ANNOUNCE
index efa998d..3fb484e 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -344,6 +344,7 @@
Recognize known sRGB ICC profiles while reading and issue a warning about
it, if PNG_WARN_IF_iCCP_IS_sRGB_SUPPORTED is defined.
Added checksum-icc.c to contrib/tools
+ Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
diff --git a/CHANGES b/CHANGES
index 50ce595..97c7e2c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4095,6 +4095,7 @@
Recognize known sRGB ICC profiles while reading and issue a warning about
it, if PNG_WARN_IF_iCCP_IS_sRGB_SUPPORTED is defined.
Added checksum-icc.c to contrib/tools
+ Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
diff --git a/pngrtran.c b/pngrtran.c
index 9419c33..ef4eca1 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1866,12 +1866,15 @@
#ifdef PNG_READ_SHIFT_SUPPORTED
if ((png_ptr->transformations & PNG_SHIFT) &&
+ !(png_ptr->transformations & PNG_EXPAND) &&
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
{
int i;
int istop = png_ptr->num_palette;
int shift = 8 - png_ptr->sig_bit.red;
+ png_ptr->transformations &= ~PNG_SHIFT;
+
/* significant bits can be in the range 1 to 7 for a meaninful result, if
* the number of significant bits is 0 then no shift is done (this is an
* error condition which is silently ignored.)