diff -ru4NwbB libpng-1.5.7/Makefile.am libpng-1.5.8/Makefile.am
--- libpng-1.5.7/Makefile.am	2011-12-15 09:45:40.090994153 -0600
+++ libpng-1.5.8/Makefile.am	2012-01-31 23:00:42.149926082 -0600
@@ -224,4 +224,5 @@
 	rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
 	rm -f $(DESTDIR)$(bindir)/libpng-config
 	rm -f $(DESTDIR)$(libdir)/libpng.a
 	rm -f $(DESTDIR)$(libdir)/libpng.la
+	rm -f $(DESTDIR)$(libdir)/libpng.dll.a
diff -ru4NwbB libpng-1.5.7/configure.ac libpng-1.5.8/configure.ac
--- libpng-1.5.7/configure.ac	2011-12-15 09:45:40.098268056 -0600
+++ libpng-1.5.8/configure.ac	2012-01-31 23:00:42.156330227 -0600
@@ -100,10 +100,8 @@
 LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG
 LIBPNG_DEFINES=$LIBPNG_DEFINES
 AC_SUBST(LIBPNG_DEFINES)
 
-AC_MSG_CHECKING([if libraries can be versioned])
-
 AC_MSG_CHECKING([if using Solaris linker])
 SLD=`$LD --version 2>&1 | grep Solaris`
 if test "$SLD"; then
     have_solaris_ld=yes
@@ -113,8 +111,9 @@
     AC_MSG_RESULT(no)
 fi
 AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
 
+AC_MSG_CHECKING([if libraries can be versioned])
 # Special case for PE/COFF platforms: ld reports
 # support for version-script, but doesn't actually
 # DO anything with it.
 case $host in
diff -ru4NwbB libpng-1.5.7/contrib/libtests/pngvalid.c libpng-1.5.8/contrib/libtests/pngvalid.c
--- libpng-1.5.7/contrib/libtests/pngvalid.c	2011-12-15 09:43:49.577464000 -0600
+++ libpng-1.5.8/contrib/libtests/pngvalid.c	2012-01-01 14:49:28.273121000 -0600
@@ -1,9 +1,9 @@
 
 /* pngvalid.c - validate libpng by constructing then reading png files.
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
- * Copyright (c) 2011 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.8 [February 1, 2012]
+ * Copyright (c) 2012 Glenn Randers-Pehrson
  * Written by John Cunningham Bowler
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -24,17 +24,20 @@
 #define _GNU_SOURCE 1 /* For the floating point exception extension */
 
 #include <signal.h>
 
-#ifdef HAVE_CONFIG_H
-#  include "../../config.h"
-#endif
-
 #ifdef HAVE_FEENABLEEXCEPT
 #  include <fenv.h>
 #endif
 
+/* Define the following to use this test against your installed libpng, rather
+ * than the one being built here:
+ */
+#ifdef PNG_FREESTANDING_TESTS
+#  include <png.h>
+#else
 #include "../../png.h"
+#endif
 
 #if PNG_LIBPNG_VER < 10500
 /* This deliberately lacks the PNG_CONST. */
 typedef png_byte *png_const_bytep;
diff -ru4NwbB libpng-1.5.7/example.c libpng-1.5.8/example.c
--- libpng-1.5.7/example.c	2011-12-15 09:45:32.458918758 -0600
+++ libpng-1.5.8/example.c	2012-01-31 23:00:34.489954887 -0600
@@ -1,9 +1,9 @@
 
 #if 0 /* in case someone actually tries to compile this */
 
 /* example.c - an example of using libpng
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Maintained 1998-2011 Glenn Randers-Pehrson
  * Maintained 1996, 1997 Andreas Dilger
  * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  */
diff -ru4NwbB libpng-1.5.7/png.c libpng-1.5.8/png.c
--- libpng-1.5.7/png.c	2011-12-15 09:45:32.471948179 -0600
+++ libpng-1.5.8/png.c	2012-01-31 23:00:34.502955796 -0600
@@ -1,8 +1,8 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/png.h libpng-1.5.8/png.h
--- libpng-1.5.7/png.h	2011-12-15 09:45:32.416549858 -0600
+++ libpng-1.5.8/png.h	2012-01-31 23:00:34.445756113 -0600
@@ -1,9 +1,9 @@
 
 /* png.h - header file for PNG reference library
  *
  * libpng version 1.5.8 - February 1, 2012
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2012 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.)
  *
  * This code is released under the libpng license (See LICENSE, below)
@@ -165,8 +165,10 @@
  *    1.5.6                   15    10506  15.so.15.6[.0]
  *    1.5.7beta01-05          15    10507  15.so.15.7[.0]
  *    1.5.7rc01-03            15    10507  15.so.15.7[.0]
  *    1.5.7                   15    10507  15.so.15.7[.0]
+ *    1.5.8beta01             15    10508  15.so.15.8[.0]
+ *    1.5.8rc01               15    10508  15.so.15.8[.0]
  *
  *   Henceforth the source version will match the shared-library major
  *   and minor numbers; the shared-library major version number will be
  *   used for changes in backward compatibility, as it is intended.  The
@@ -197,9 +199,9 @@
  *
  * This code is released under the libpng license.
  *
  * libpng versions 1.2.6, August 15, 2004, through 1.5.8, February 1, 2012, are
- * Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
+ * Copyright (c) 2004, 2006-2012 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:
  *
  *    Cosmin Truta
diff -ru4NwbB libpng-1.5.7/pngconf.h libpng-1.5.8/pngconf.h
--- libpng-1.5.7/pngconf.h	2011-12-15 09:45:32.423656205 -0600
+++ libpng-1.5.8/pngconf.h	2012-01-31 23:00:34.453453019 -0600
@@ -2,9 +2,9 @@
 /* pngconf.h - machine configurable file for libpng
  *
  * libpng version 1.5.8 - February 1, 2012
  *
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2012 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.)
  *
  * This code is released under the libpng license.
diff -ru4NwbB libpng-1.5.7/pngerror.c libpng-1.5.8/pngerror.c
--- libpng-1.5.7/pngerror.c	2011-12-15 09:45:32.479000733 -0600
+++ libpng-1.5.8/pngerror.c	2012-01-31 23:00:34.510129046 -0600
@@ -1,9 +1,9 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
  * Last changed in libpng 1.5.7 [February 1, 2012]
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2012 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.)
  *
  * This code is released under the libpng license.
@@ -280,37 +280,42 @@
 void
 png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
    png_const_charp message)
 {
-   /* The internal buffer is just 128 bytes - enough for all our messages,
-    * overflow doesn't happen because this code checks!
+   /* The internal buffer is just 192 bytes - enough for all our messages,
+    * overflow doesn't happen because this code checks!  If someone figures
+    * out how to send us a message longer than 192 bytes, all that will
+    * happen is that the message will be truncated appropriately.
     */
-   size_t i;
-   char msg[128];
+   size_t i = 0; /* Index in the msg[] buffer: */
+   char msg[192];
 
-   for (i=0; i<(sizeof msg)-1 && *message != '\0'; ++i)
-   {
-      if (*message == '@')
+   /* Each iteration through the following loop writes at most one character
+    * to msg[i++] then returns here to validate that there is still space for
+    * the trailing '\0'.  It may (in the case of a parameter) read more than
+    * one character from message[]; it must check for '\0' and continue to the
+    * test if it finds the end of string.
+    */
+   while (i<(sizeof msg)-1 && *message != '\0')
       {
-         int parameter = -1;
-         switch (*++message)
+      /* '@' at end of string is now just printed (previously it was skipped);
+       * it is an error in the calling code to terminate the string with @.
+       */
+      if (p != NULL && *message == '@' && message[1] != '\0')
          {
-            case '1':
-               parameter = 0;
-               break;
-
-            case '2':
-               parameter = 1;
-               break;
+         int parameter_char = *++message; /* Consume the '@' */
+         static const char valid_parameters[] = "123456789";
+         int parameter = 0;
 
-            case '\0':
-               continue; /* To break out of the for loop above. */
-
-            default:
-               break;
-         }
+         /* Search for the parameter digit, the index in the string is the
+          * parameter to use.
+          */
+         while (valid_parameters[parameter] != parameter_char &&
+            valid_parameters[parameter] != '\0')
+            ++parameter;
 
-         if (parameter >= 0 && parameter < PNG_WARNING_PARAMETER_COUNT)
+         /* If the parameter digit is out of range it will just get printed. */
+         if (parameter < PNG_WARNING_PARAMETER_COUNT)
          {
             /* Append this parameter */
             png_const_charp parm = p[parameter];
             png_const_charp pend = p[parameter] + (sizeof p[parameter]);
@@ -318,30 +323,34 @@
             /* No need to copy the trailing '\0' here, but there is no guarantee
              * that parm[] has been initialized, so there is no guarantee of a
              * trailing '\0':
              */
-            for (; i<(sizeof msg)-1 && parm != '\0' && parm < pend; ++i)
-               msg[i] = *parm++;
+            while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend)
+               msg[i++] = *parm++;
 
+            /* Consume the parameter digit too: */
             ++message;
             continue;
          }
 
          /* else not a parameter and there is a character after the @ sign; just
-          * copy that.
+          * copy that.  This is known not to be '\0' because of the test above.
           */
       }
 
       /* At this point *message can't be '\0', even in the bad parameter case
        * above where there is a lone '@' at the end of the message string.
        */
-      msg[i] = *message++;
+      msg[i++] = *message++;
    }
 
    /* i is always less than (sizeof msg), so: */
    msg[i] = '\0';
 
-   /* And this is the formatted message: */
+   /* And this is the formatted message, it may be larger than
+    * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are
+    * not (currently) formatted.
+    */
    png_warning(png_ptr, msg);
 }
 #endif /* PNG_WARNINGS_SUPPORTED */
 
diff -ru4NwbB libpng-1.5.7/pngget.c libpng-1.5.8/pngget.c
--- libpng-1.5.7/pngget.c	2011-12-15 09:45:32.487133629 -0600
+++ libpng-1.5.8/pngget.c	2012-01-31 23:00:34.518487225 -0600
@@ -1,8 +1,8 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/pngmem.c libpng-1.5.8/pngmem.c
--- libpng-1.5.7/pngmem.c	2011-12-15 09:45:32.494039954 -0600
+++ libpng-1.5.8/pngmem.c	2012-01-31 23:00:34.525400444 -0600
@@ -1,8 +1,8 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/pngpread.c libpng-1.5.8/pngpread.c
--- libpng-1.5.7/pngpread.c	2011-12-15 09:45:32.503773794 -0600
+++ libpng-1.5.8/pngpread.c	2012-01-31 23:00:34.535207967 -0600
@@ -1,8 +1,8 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/pngpriv.h libpng-1.5.8/pngpriv.h
--- libpng-1.5.7/pngpriv.h	2011-12-15 09:45:32.433566044 -0600
+++ libpng-1.5.8/pngpriv.h	2012-01-31 23:00:34.463751709 -0600
@@ -5,9 +5,9 @@
  * Copyright (c) 1998-2011 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.)
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
diff -ru4NwbB libpng-1.5.7/pngread.c libpng-1.5.8/pngread.c
--- libpng-1.5.7/pngread.c	2011-12-15 09:45:32.512490496 -0600
+++ libpng-1.5.8/pngread.c	2012-01-31 23:00:34.543855437 -0600
@@ -1,8 +1,8 @@
 
 /* pngread.c - read a PNG file
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/pngrtran.c libpng-1.5.8/pngrtran.c
--- libpng-1.5.7/pngrtran.c	2011-12-15 09:45:32.535877370 -0600
+++ libpng-1.5.8/pngrtran.c	2012-01-31 23:00:34.567837915 -0600
@@ -1,8 +1,8 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/pngrutil.c libpng-1.5.8/pngrutil.c
--- libpng-1.5.7/pngrutil.c	2011-12-15 09:45:32.551997710 -0600
+++ libpng-1.5.8/pngrutil.c	2012-01-31 23:00:34.584175014 -0600
@@ -1,8 +1,8 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/pngset.c libpng-1.5.8/pngset.c
--- libpng-1.5.7/pngset.c	2011-12-15 09:45:32.560605984 -0600
+++ libpng-1.5.8/pngset.c	2012-01-31 23:00:34.592794088 -0600
@@ -1,8 +1,8 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/pngwrite.c libpng-1.5.8/pngwrite.c
--- libpng-1.5.7/pngwrite.c	2011-12-15 09:45:32.592488881 -0600
+++ libpng-1.5.8/pngwrite.c	2012-01-31 23:00:34.624963537 -0600
@@ -1,8 +1,8 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * Last changed in libpng 1.5.7 [February 1, 2012]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 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 -ru4NwbB libpng-1.5.7/scripts/def.dfn libpng-1.5.8/scripts/def.dfn
--- libpng-1.5.7/scripts/def.dfn	2011-11-03 16:13:57.945898000 -0500
+++ libpng-1.5.8/scripts/def.dfn	2011-12-21 08:48:13.428450000 -0600
@@ -1,7 +1,7 @@
 /* def.dfn - define format of libpng.def
  *
- * Last changed in libpng version 1.5.0 [(PENDING RELEASE)]
+ * Last changed in libpng version 1.5.7 [December 15, 2011]
  * Copyright (c) 2010-2011 Glenn Randers-Pehrson
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff -ru4NwbB libpng-1.5.7/scripts/options.awk libpng-1.5.8/scripts/options.awk
--- libpng-1.5.7/scripts/options.awk	2011-12-15 09:45:34.870841056 -0600
+++ libpng-1.5.8/scripts/options.awk	2011-12-21 08:50:53.995640000 -0600
@@ -1,8 +1,8 @@
 #!/bin/awk -f
 # scripts/options.awk - library build configuration control
 #
-# last changed in libpng version 1.5.7 - February 1, 2012
+# last changed in libpng version 1.5.7 - December 15, 2011
 #
 # Copyright (c) 1998-2011 Glenn Randers-Pehrson
 #
 # This code is released under the libpng license.