Merge branch 'libpng16' of git://github.com/barkovv/libpng into libpng16
diff --git a/ANNOUNCE b/ANNOUNCE
index f982888..ed47742 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,4 +1,4 @@
-Libpng 1.6.29beta02 - January 20, 2017
+Libpng 1.6.29beta02 - February 22, 2017
 
 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.
@@ -32,9 +32,11 @@
     libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it.
   Simplified conditional compilation in pngvalid.c, for AIX (Michael Felt).
 
-Version 1.6.29beta02 [January 20, 2017]
+Version 1.6.29beta02 [February 22, 2017]
   Avoid conditional directives that break statements in pngrutil.c (Romero
     Malaquias)
+  The contrib/examples/pngtopng.c recovery code was in the wrong if
+    branches; the comments were correct.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/CHANGES b/CHANGES
index fda475b..8c1b8fb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5801,9 +5801,11 @@
     libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it.
   Simplified conditional compilation in pngvalid.c, for AIX (Michael Felt).
 
-Version 1.6.29beta02 [January 20, 2017]
+Version 1.6.29beta02 [February 22, 2017]
   Avoid conditional directives that break statements in pngrutil.c (Romero
     Malaquias)
+  The contrib/examples/pngtopng.c recovery code was in the wrong if
+    branches; the comments were correct.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/README b/README
index 5d3a4c7..b218467 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng version 1.6.29beta02 - January 12, 2017 (shared library 16.0)
+README for libpng version 1.6.29beta02 - January 31, 2017 (shared library 16.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -187,8 +187,8 @@
        gregbook         =>  source code for PNG reading and writing, from
                             Greg Roelofs' "PNG: The Definitive Guide",
                             O'Reilly, 1999
-       intel            =>  Optimized code for INTEL-SSE2 platform
        libtests         =>  Test programs
+       mips-msa         =>  Optimized code for MIPS-MSA platform
        pngminim         =>  Minimal decoder, encoder, and progressive decoder
                             programs demonstrating use of pngusr.dfa
        pngminus         =>  Simple pnm2png and png2pnm programs
@@ -196,6 +196,8 @@
        testpngs
        tools            =>  Various tools
        visupng          =>  Contains a MSVC workspace for VisualPng
+      intel             =>  Optimized code for INTEL-SSE2 platform
+      mips              =>  Optimized code for MIPS platform
       projects      =>  Contains project files and workspaces for
                         building a DLL
        owatcom          =>  Contains a WATCOM project for building libpng
diff --git a/contrib/examples/pngtopng.c b/contrib/examples/pngtopng.c
index 4acf6b3..1d83330 100644
--- a/contrib/examples/pngtopng.c
+++ b/contrib/examples/pngtopng.c
@@ -59,26 +59,27 @@
                else
                   fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
                       image.message);
-
-               free(buffer);
             }
 
             else
-            {
                fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
                    image.message);
 
-               /* This is the only place where a 'free' is required; libpng does
-                * the cleanup on error and success, but in this case we couldn't
-                * complete the read because of running out of memory.
-                */
-               png_image_free(&image);
-            }
+            free(buffer);
          }
 
          else
+         {
             fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
                (unsigned long)PNG_IMAGE_SIZE(image));
+
+            /* This is the only place where a 'free' is required; libpng does
+             * the cleanup on error and success, but in this case we couldn't
+             * complete the read because of running out of memory and so libpng
+             * has not got to the point where it can do cleanup.
+             */
+            png_image_free(&image);
+         }
       }
 
       else