[libpng15] Imported from libpng-1.5.22beta01.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index b462c6a..b62f181 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.5.22beta01 - January 13, 2015
+Libpng 1.5.22beta01 - January 28, 2015
 
 This is not intended to be a public release.  It will be replaced
 within a few weeks by a public version or by another test version.
@@ -27,10 +27,11 @@
 
 Changes since the last public release (1.5.21):
 
-Version 1.5.22beta01 [January 13, 2015]
+Version 1.5.22beta01 [January 28, 2015]
   Regenerated configure scripts with libtool-2.4.4
   Made the check for out-of-range values in png_set_tRNS() detect
     values that are exactly 2^bit_depth, and work on 16-bit platforms.
+  Quieted some warnings from Coverity-scan.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/CHANGES b/CHANGES
index b5dec2b..09198e5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4291,10 +4291,11 @@
 Version 1.5.21 [December 22, 2014]
   No changes.
 
-Version 1.5.22beta01 [January 13, 2015]
+Version 1.5.22beta01 [January 28, 2015]
   Regenerated configure scripts with libtool-2.4.4
   Made the check for out-of-range values in png_set_tRNS() detect
     values that are exactly 2^bit_depth, and work on 16-bit platforms.
+  Quieted some warnings from Coverity-scan.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/LICENSE b/LICENSE
index dacb6fb..52898c1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -10,7 +10,7 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.5.22beta01, December 22, 2014, are
+libpng versions 1.2.6, August 15, 2004, through 1.5.22beta01, January 28, 2015, are
 Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
@@ -108,4 +108,4 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-December 22, 2014
+January 28, 2015
diff --git a/README b/README
index 6a0babc..baa30bb 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng version 1.5.22beta01 - December 22, 2014 (shared library 15.0)
+README for libpng version 1.5.22beta01 - January 28, 2015 (shared library 15.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
diff --git a/libpng-manual.txt b/libpng-manual.txt
index 8dcc136..6083a75 100644
--- a/libpng-manual.txt
+++ b/libpng-manual.txt
@@ -1,6 +1,6 @@
 Libpng-manual.txt - A description on how to use and modify libpng
 
- libpng version 1.5.22beta01 - December 22, 2014
+ libpng version 1.5.22beta01 - January 28, 2015
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -11,7 +11,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.5.22beta01 - December 22, 2014
+ libpng versions 0.97, January 1998, through 1.5.22beta01 - January 28, 2015
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2014 Glenn Randers-Pehrson
 
@@ -4531,7 +4531,7 @@
 
 XIV. Y2K Compliance in libpng
 
-December 22, 2014
+January 28, 2015
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
diff --git a/libpng.3 b/libpng.3
index 5bf49f0..b8399e5 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,4 +1,4 @@
-.TH LIBPNG 3 "December 22, 2014"
+.TH LIBPNG 3 "January 28, 2015"
 .SH NAME
 libpng \- Portable Network Graphics (PNG) Reference Library 1.5.22beta01
 .SH SYNOPSIS
@@ -492,7 +492,7 @@
 .SH LIBPNG.TXT
 Libpng-manual.txt - A description on how to use and modify libpng
 
- libpng version 1.5.22beta01 - December 22, 2014
+ libpng version 1.5.22beta01 - January 28, 2015
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -503,7 +503,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.5.22beta01 - December 22, 2014
+ libpng versions 0.97, January 1998, through 1.5.22beta01 - January 28, 2015
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2014 Glenn Randers-Pehrson
 
@@ -5023,7 +5023,7 @@
 
 .SH XIV. Y2K Compliance in libpng
 
-December 22, 2014
+January 28, 2015
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
@@ -5330,7 +5330,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.5.22beta01 - December 22, 2014:
+Libpng version 1.5.22beta01 - January 28, 2015:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
 
@@ -5353,7 +5353,7 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.5.22beta01, December 22, 2014, are
+libpng versions 1.2.6, August 15, 2004, through 1.5.22beta01, January 28, 2015, are
 Copyright (c) 2004,2006-20014 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
@@ -5452,7 +5452,7 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-December 22, 2014
+January 28, 2015
 
 .\" end of man page
 
diff --git a/libpngpf.3 b/libpngpf.3
index e0808b7..52bb4ec 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,4 +1,4 @@
-.TH LIBPNGPF 3 "December 22, 2014"
+.TH LIBPNGPF 3 "January 28, 2015"
 .SH NAME
 libpng \- Portable Network Graphics (PNG) Reference Library 1.5.22beta01
 (private functions)
diff --git a/png.5 b/png.5
index ff6083c..b27d180 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "December 22, 2014"
+.TH PNG 5 "January 28, 2015"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index 2d64330..4132f4d 100644
--- a/png.c
+++ b/png.c
@@ -1,8 +1,8 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * Last changed in libpng 1.5.21 [December 22, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.22 [(PENDING RELEASE)]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -149,9 +149,10 @@
       do
       {
          uInt safeLength = (uInt)length;
+#ifndef __COVERITY__
          if (safeLength == 0)
             safeLength = (uInt)-1; /* evil, but safe */
-
+#endif
          crc = crc32(crc, ptr, safeLength);
 
          /* The following should never issue compiler warnings, if they do the
@@ -660,13 +661,13 @@
 #else
 #  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-     "libpng version 1.5.22beta01 - December 22, 2014" PNG_STRING_NEWLINE \
+     "libpng version 1.5.22beta01 - January 28, 2015" PNG_STRING_NEWLINE \
      "Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
      "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
      "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
      PNG_STRING_NEWLINE;
 #  else
-      return "libpng version 1.5.22beta01 - December 22, 2014\
+      return "libpng version 1.5.22beta01 - January 28, 2015\
       Copyright (c) 1998-2014 Glenn Randers-Pehrson\
       Copyright (c) 1996-1997 Andreas Dilger\
       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -2081,17 +2082,20 @@
 png_fixed_point
 png_reciprocal(png_fixed_point a)
 {
+   if (a != 0)
+   {
 #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
-   double r = floor(1E10/a+.5);
+     double r = floor(1E10/a+.5);
 
-   if (r <= 2147483647. && r >= -2147483648.)
-      return (png_fixed_point)r;
+     if (r <= 2147483647. && r >= -2147483648.)
+        return (png_fixed_point)r;
 #else
-   png_fixed_point res;
+     png_fixed_point res;
 
-   if (png_muldiv(&res, 100000, 100000, a))
-      return res;
+     if (png_muldiv(&res, 100000, 100000, a))
+        return res;
 #endif
+   }
 
    return 0; /* error/overflow */
 }
@@ -2126,23 +2130,26 @@
 {
    /* The required result is 1/a * 1/b; the following preserves accuracy. */
 #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
-   double r = 1E15/a;
-   r /= b;
-   r = floor(r+.5);
+   if (a != 0 && b != 0)
+   {
+      double r = 1E15/a;
+      r /= b;
+      r = floor(r+.5);
 
-   if (r <= 2147483647. && r >= -2147483648.)
-      return (png_fixed_point)r;
+      if (r <= 2147483647. && r >= -2147483648.)
+         return (png_fixed_point)r;
 #else
-   /* This may overflow because the range of png_fixed_point isn't symmetric,
-    * but this API is only used for the product of file and screen gamma so it
-    * doesn't matter that the smallest number it can produce is 1/21474, not
-    * 1/100000
-    */
-   png_fixed_point res = png_product2(a, b);
+      /* This may overflow because the range of png_fixed_point isn't
+       * symmetric, but this API is only used for the product of file and
+       * screen gamma so it doesn't matter that the smallest number it can
+       * produce is 1/21474, not 1/100000
+       */
+      png_fixed_point res = png_product2(a, b);
 
-   if (res != 0)
-      return png_reciprocal(res);
+      if (res != 0)
+         return png_reciprocal(res);
 #endif
+   }
 
    return 0; /* overflow */
 }
diff --git a/png.h b/png.h
index 4e10e02..a27bd68 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.5.22beta01 - December 22, 2014
+ * libpng version 1.5.22beta01 - January 28, 2015
  * Copyright (c) 1998-2014 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -11,7 +11,7 @@
  * Authors and maintainers:
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- *   libpng versions 0.97, January 1998, through 1.5.22beta01 - December 22, 2014: Glenn
+ *   libpng versions 0.97, January 1998, through 1.5.22beta01 - January 28, 2015: Glenn
  *   See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -237,7 +237,7 @@
  *
  * This code is released under the libpng license.
  *
- * libpng versions 1.2.6, August 15, 2004, through 1.5.22beta01, December 22, 2014, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.5.22beta01, January 28, 2015, are
  * Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
  * distributed according to the same disclaimer and license as libpng-1.2.5
  * with the following individual added to the list of Contributing Authors:
@@ -349,7 +349,7 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    December 22, 2014
+ *    January 28, 2015
  *
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
@@ -418,7 +418,7 @@
 /* Version information for png.h - this should match the version in png.c */
 #define PNG_LIBPNG_VER_STRING "1.5.22beta01"
 #define PNG_HEADER_VERSION_STRING \
-     " libpng version 1.5.22beta01 - December 22, 2014\n"
+     " libpng version 1.5.22beta01 - January 28, 2015\n"
 
 #define PNG_LIBPNG_VER_SONUM   15
 #define PNG_LIBPNG_VER_DLLNUM  15
diff --git a/pngconf.h b/pngconf.h
index 4773b7a..55a8818 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.5.22beta01 - December 22, 2014
+ * libpng version 1.5.22beta01 - January 28, 2015
  *
  * Copyright (c) 1998-2013 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngrtran.c b/pngrtran.c
index d0684c2..bdb51fc 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,8 +1,8 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * Last changed in libpng 1.5.19 [August 21, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.22 [(PENDING RELEASE)]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -3341,11 +3341,17 @@
             for (i = 0; i < row_width; i++)
             {
                png_uint_16 red, green, blue, w;
-
+#if 0 /* Coverity doesn't like this */
                red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
                green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
                blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
+#else
+               png_byte hi,lo;
 
+               hi=*(sp)++; lo=*(sp)++; red   = (png_uint_16)((hi << 8) | (lo));
+               hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
+               hi=*(sp)++; lo=*(sp)++; blue  = (png_uint_16)((hi << 8) | (lo));
+#endif
                if (red == green && red == blue)
                {
                   if (png_ptr->gamma_16_table != NULL)
diff --git a/pngrutil.c b/pngrutil.c
index b46dced..4c04933 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,8 +1,8 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * Last changed in libpng 1.5.21 [December 22, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.22 [(PENDING RELEASE)]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -2549,20 +2549,23 @@
     * compression type]".  The compression flag shall be 0 (no compression) or
     * 1 (compressed with method 0 - deflate.)
     */
-   if (comp_flag != 0 && comp_flag != 1)
+   if (comp_flag/*compressed*/ != 0)
    {
-      png_warning(png_ptr, "invalid iTXt compression flag");
-      png_free(png_ptr, png_ptr->chunkdata);
-      png_ptr->chunkdata = NULL;
-      return;
-   }
+     if (comp_flag != 1)
+     {
+        png_warning(png_ptr, "invalid iTXt compression flag");
+        png_free(png_ptr, png_ptr->chunkdata);
+        png_ptr->chunkdata = NULL;
+        return;
+     }
 
-   if (comp_flag/*compressed*/ && comp_type != 0)
-   {
-      png_warning(png_ptr, "unknown iTXt compression type");
-      png_free(png_ptr, png_ptr->chunkdata);
-      png_ptr->chunkdata = NULL;
-      return;
+     if (comp_type != 0)
+     {
+        png_warning(png_ptr, "unknown iTXt compression type");
+        png_free(png_ptr, png_ptr->chunkdata);
+        png_ptr->chunkdata = NULL;
+        return;
+     }
    }
 
    for (lang_key = lang; *lang_key; lang_key++)
diff --git a/pngset.c b/pngset.c
index 64d452d..4886d8d 100644
--- a/pngset.c
+++ b/pngset.c
@@ -2,7 +2,7 @@
 /* pngset.c - storage of image information into info struct
  *
  * Last changed in libpng 1.5.22 [(PENDING RELEASE)]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
diff --git a/projects/vstudio/readme.txt b/projects/vstudio/readme.txt
index d26594b..3907b6e 100644
--- a/projects/vstudio/readme.txt
+++ b/projects/vstudio/readme.txt
@@ -1,7 +1,7 @@
 
 VisualStudio instructions
 
-libpng version 1.5.22beta01 - December 22, 2014
+libpng version 1.5.22beta01 - January 28, 2015
 
 Copyright (c) 1998-2010 Glenn Randers-Pehrson
 
diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props
index 1f4d60b..78e1d9b 100644
--- a/projects/vstudio/zlib.props
+++ b/projects/vstudio/zlib.props
@@ -2,7 +2,7 @@
 <!--
  * zlib.props - location of zlib source
  *
- * libpng version 1.5.22beta01 - December 22, 2014
+ * libpng version 1.5.22beta01 - January 28, 2015
  *
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  *
diff --git a/scripts/README.txt b/scripts/README.txt
index 058509c..d4f064e 100644
--- a/scripts/README.txt
+++ b/scripts/README.txt
@@ -1,5 +1,5 @@
 
-Makefiles for  libpng version 1.5.22beta01 - December 22, 2014
+Makefiles for  libpng version 1.5.22beta01 - January 28, 2015
 
 pnglibconf.h.prebuilt       =>  Stores configuration settings
  makefile.linux    =>  Linux/ELF makefile
diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt
index c9a0027..50f59d9 100644
--- a/scripts/pnglibconf.h.prebuilt
+++ b/scripts/pnglibconf.h.prebuilt
@@ -1,7 +1,7 @@
 /* 1.5.22beta01 STANDARD API DEFINITION */
 /* pnglibconf.h - library build configuration */
 
-/* libpng version 1.5.22beta01 - December 22, 2014 */
+/* libpng version 1.5.22beta01 - January 28, 2015 */
 
 /* Copyright (c) 1998-2013 Glenn Randers-Pehrson */