Imported from libpng-1.2.36beta02.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index 3eac7e9..87bf52a 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.2.36beta01 - February 28, 2009
+Libpng 1.2.36beta02 - March 21, 2009
 
 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.
@@ -9,37 +9,37 @@
 Source files with LF line endings (for Unix/Linux) and with a
 "configure" script
 
-   libpng-1.2.36beta01.tar.gz
-   libpng-1.2.36beta01.tar.lzma
+   libpng-1.2.36beta02.tar.gz
+   libpng-1.2.36beta02.tar.lzma
      (Get the lzma codec from <http://tukaani.org/lzma>).
-   libpng-1.2.36beta01.tar.bz2
+   libpng-1.2.36beta02.tar.bz2
 
 Source files with LF line endings (for Unix/Linux) without the
 "configure" script
 
-   libpng-1.2.36beta01-no-config.tar.gz
-   libpng-1.2.36beta01-no-config.tar.lzma
-   libpng-1.2.36beta01-no-config.tar.bz2
+   libpng-1.2.36beta02-no-config.tar.gz
+   libpng-1.2.36beta02-no-config.tar.lzma
+   libpng-1.2.36beta02-no-config.tar.bz2
 
 Source files with CRLF line endings (for Windows), without the
 "configure" script
 
-   lp1236b01.zip
-   lp1236b01.7z
-   lp1236b01.tar.bz2
+   lp1236b02.zip
+   lp1236b02.7z
+   lp1236b02.tar.bz2
 
 Project files
 
-   libpng-1.2.36beta01-project-netware.zip
-   libpng-1.2.36beta01-project-wince.zip
+   libpng-1.2.36beta02-project-netware.zip
+   libpng-1.2.36beta02-project-wince.zip
 
 Other information:
 
-   libpng-1.2.36beta01-README.txt
-   libpng-1.2.36beta01-KNOWNBUGS.txt
-   libpng-1.2.36beta01-LICENSE.txt
-   libpng-1.2.36beta01-Y2K-compliance.txt
-   libpng-1.2.36beta01-[previous version]-diff.txt
+   libpng-1.2.36beta02-README.txt
+   libpng-1.2.36beta02-KNOWNBUGS.txt
+   libpng-1.2.36beta02-LICENSE.txt
+   libpng-1.2.36beta02-Y2K-compliance.txt
+   libpng-1.2.36beta02-[previous version]-diff.txt
 
 Changes since the last public release (1.2.34):
 
@@ -67,6 +67,15 @@
   Revised order of #ifdef's and indentation in png_debug definitions of png.h
     bug introduced in libpng-1.2.34.
 
+version 1.2.36beta02 [March 21, 2009]
+  Use png_memset() after png_malloc() of big_row_buf when reading an
+    interlaced file, to avoid a possible UMR.
+  Undid recent revision of PNG_NO_STDIO version of png_write_flush().  Users
+    having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined.
+  Revised libpng*.txt documentation about use of png_write_flush().
+  Removed fflush() from pngtest.c.
+  Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h
+
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 
 (subscription required; visit 
diff --git a/CHANGES b/CHANGES
index 4db3cc1..a1b6861 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2334,6 +2334,15 @@
   Revised order of #ifdef's and indentation in png_debug definitions of png.h
     bug introduced in libpng-1.2.34.
 
+version 1.2.36beta02 [March 21, 2009]
+  Use png_memset() after png_malloc() of big_row_buf when reading an
+    interlaced file, to avoid a possible UMR.
+  Undid recent revision of PNG_NO_STDIO version of png_write_flush().  Users
+    having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined.
+  Revised libpng*.txt documentation about use of png_write_flush().
+  Removed fflush() from pngtest.c.
+  Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h
+
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
diff --git a/INSTALL b/INSTALL
index cd90b48..2c79ceb 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.2.36beta01 - February 28, 2009
+Installing libpng version 1.2.36beta02 - March 21, 2009
 
 On Unix/Linux and similar systems, you can simply type
 
@@ -44,7 +44,7 @@
 correspond to the version of zlib that's installed.
 
 You can rename the directories that you downloaded (they
-might be called "libpng-1.2.36beta01" or "lpng109" and "zlib-1.2.1"
+might be called "libpng-1.2.36beta02" or "lpng109" and "zlib-1.2.1"
 or "zlib121") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
@@ -101,9 +101,9 @@
  CMakeLists.txt    =>  "cmake" script
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
  makefile.elf      =>  Linux/ELF makefile symbol versioning,
-                       gcc, creates libpng12.so.0.1.2.36beta01)
+                       gcc, creates libpng12.so.0.1.2.36beta02)
  makefile.linux    =>  Linux/ELF makefile
-                       (gcc, creates libpng12.so.0.1.2.36beta01)
+                       (gcc, creates libpng12.so.0.1.2.36beta02)
  makefile.gcc      =>  Generic makefile (gcc, creates static libpng.a)
  makefile.knr      =>  Archaic UNIX Makefile that converts files with
                        ansi2knr (Requires ansi2knr.c from
@@ -125,14 +125,14 @@
  makefile.openbsd  =>  OpenBSD makefile
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
  makefile.sggcc    =>  Silicon Graphics (gcc,
-                       creates libpng12.so.0.1.2.36beta01)
+                       creates libpng12.so.0.1.2.36beta02)
  makefile.sunos    =>  Sun makefile
  makefile.solaris  =>  Solaris 2.X makefile (gcc,
-                       creates libpng12.so.0.1.2.36beta01)
+                       creates libpng12.so.0.1.2.36beta02)
  makefile.solaris-x86 =>  Solaris/intelMMX 2.X makefile (gcc,
-                       creates libpng12.so.0.1.2.36beta01)
+                       creates libpng12.so.0.1.2.36beta02)
  makefile.so9      =>  Solaris 9 makefile (gcc,
-                       creates libpng12.so.0.1.2.36beta01)
+                       creates libpng12.so.0.1.2.36beta02)
  makefile.32sunu   =>  Sun Ultra 32-bit makefile
  makefile.64sunu   =>  Sun Ultra 64-bit makefile
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
diff --git a/KNOWNBUG b/KNOWNBUG
index 10261ff..5621b58 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -1,5 +1,5 @@
 
-Known bugs in libpng version 1.2.36beta01
+Known bugs in libpng version 1.2.36beta02
 
 1. February 23, 2006: The custom makefiles don't build libpng with -lz.
 
diff --git a/LICENSE b/LICENSE
index 7ac0091..f6af8d5 100644
--- a/LICENSE
+++ b/LICENSE
@@ -8,7 +8,7 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.2.6, August 15, 2004, through 1.2.36beta01, February 28, 2009, are
+libpng versions 1.2.6, August 15, 2004, through 1.2.36beta02, March 21, 2009, are
 Copyright (c) 2004, 2006-2008 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
@@ -106,4 +106,4 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-February 28, 2009
+March 21, 2009
diff --git a/Makefile.am b/Makefile.am
index fd1aca4..92202fc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -86,7 +86,7 @@
 	${srcdir}/contrib/pngsuite/* \
 	${srcdir}/contrib/visupng/* \
 	$(TESTS) \
-	example.c libpng-1.2.36beta01.txt pngvcrd.c 
+	example.c libpng-1.2.36beta02.txt pngvcrd.c 
 
 CLEANFILES= pngout.png libpng12.pc libpng12-config libpng.vers \
 libpng.sym
diff --git a/Makefile.in b/Makefile.in
index 6bc77d1..81072f9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -331,7 +331,7 @@
 	${srcdir}/contrib/pngsuite/* \
 	${srcdir}/contrib/visupng/* \
 	$(TESTS) \
-	example.c libpng-1.2.36beta01.txt pngvcrd.c 
+	example.c libpng-1.2.36beta02.txt pngvcrd.c 
 
 CLEANFILES = pngout.png libpng12.pc libpng12-config libpng.vers \
 libpng.sym
diff --git a/README b/README
index b6d31d9..a2e8732 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng version 1.2.36beta01 - February 28, 2009 (shared library 12.0)
+README for libpng version 1.2.36beta02 - March 21, 2009 (shared library 12.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -194,11 +194,11 @@
        descrip.mms      =>  VMS makefile for MMS or MMK
        makefile.std     =>  Generic UNIX makefile (cc, creates static libpng.a)
        makefile.elf     =>  Linux/ELF makefile symbol versioning,
-                            gcc, creates libpng12.so.0.1.2.36beta01)
+                            gcc, creates libpng12.so.0.1.2.36beta02)
        makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng12.so.0.1.2.36beta01)
+                            (gcc, creates libpng12.so.0.1.2.36beta02)
        makefile.gcmmx   =>  Linux/ELF makefile
-                            (gcc, creates libpng12.so.0.1.2.36beta01,
+                            (gcc, creates libpng12.so.0.1.2.36beta02,
                             uses assembler code tuned for Intel MMX platform)
        makefile.gcc     =>  Generic makefile (gcc, creates static libpng.a)
        makefile.knr     =>  Archaic UNIX Makefile that converts files with
@@ -220,12 +220,12 @@
        makefile.openbsd =>  OpenBSD makefile
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
        makefile.sggcc   =>  Silicon Graphics
-                            (gcc, creates libpng12.so.0.1.2.36beta01)
+                            (gcc, creates libpng12.so.0.1.2.36beta02)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng12.so.0.1.2.36beta01)
+                            (gcc, creates libpng12.so.0.1.2.36beta02)
        makefile.so9     =>  Solaris 9 makefile
-                            (gcc, creates libpng12.so.0.1.2.36beta01)
+                            (gcc, creates libpng12.so.0.1.2.36beta02)
        makefile.32sunu  =>  Sun Ultra 32-bit makefile
        makefile.64sunu  =>  Sun Ultra 64-bit makefile
        makefile.sco     =>  For SCO OSr5  ELF and Unixware 7 with Native cc
diff --git a/Y2KINFO b/Y2KINFO
index 5bc667a..bfb7506 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      February 28, 2009
+      March 21, 2009
 
       Since the PNG Development group is an ad-hoc body, we can't make
       an official declaration.
 
       This is your unofficial assurance that libpng from version 0.71 and
-      upward through 1.2.36beta01 are Y2K compliant.  It is my belief that earlier
+      upward through 1.2.36beta02 are Y2K compliant.  It is my belief that earlier
       versions were also Y2K compliant.
 
       Libpng only has three year fields.  One is a 2-byte unsigned integer
diff --git a/configure b/configure
index ea04ca8..6224d0c 100755
--- a/configure
+++ b/configure
Binary files differ
diff --git a/configure.ac b/configure.ac
index f8bf783..4c7c440 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,12 +18,12 @@
 
 dnl Version number stuff here:
 
-AC_INIT([libpng], [1.2.36beta01], [png-mng-implement@lists.sourceforge.net])
+AC_INIT([libpng], [1.2.36beta02], [png-mng-implement@lists.sourceforge.net])
 AM_INIT_AUTOMAKE
 dnl stop configure from automagically running automake
 AM_MAINTAINER_MODE
 
-PNGLIB_VERSION=1.2.36beta01
+PNGLIB_VERSION=1.2.36beta02
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=2
 PNGLIB_RELEASE=36
diff --git a/contrib/pngminim/encoder/pngusr.h b/contrib/pngminim/encoder/pngusr.h
index 904673a..18989d1 100644
--- a/contrib/pngminim/encoder/pngusr.h
+++ b/contrib/pngminim/encoder/pngusr.h
@@ -51,6 +51,7 @@
 #define PNG_NO_WRITE_FILTER
 #define PNG_NO_WRITE_WEIGHTED_FILTER
 #define PNG_NO_WRITE_INTERLACING_SUPPORTED
+#define PNG_NO_WRITE_FLUSH
 
 #define PNG_NO_INFO_IMAGE
 #define PNG_NO_USER_MEM
diff --git a/example.c b/example.c
index 48b24dd..d8c2f48 100644
--- a/example.c
+++ b/example.c
@@ -2,7 +2,7 @@
 #if 0 /* in case someone actually tries to compile this */
 
 /* example.c - an example of using libpng
- * Last changed in libpng 1.2.35 [February 14, 2009]
+ * Last changed in libpng 1.2.36 [March 21, 2009]
  * This file has been placed in the public domain by the authors.
  * Maintained 1998-2009 Glenn Randers-Pehrson
  * Maintained 1996, 1997 Andreas Dilger)
diff --git a/libpng-1.2.36beta01.txt b/libpng-1.2.36beta02.txt
similarity index 97%
rename from libpng-1.2.36beta01.txt
rename to libpng-1.2.36beta02.txt
index b853b11..056c74f 100644
--- a/libpng-1.2.36beta01.txt
+++ b/libpng-1.2.36beta02.txt
@@ -1,6 +1,6 @@
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.2.36beta01 - February 28, 2009
+ libpng version 1.2.36beta02 - March 21, 2009
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2009 Glenn Randers-Pehrson
@@ -9,7 +9,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.2.36beta01 - February 28, 2009
+ libpng versions 0.97, January 1998, through 1.2.36beta02 - March 21, 2009
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2008 Glenn Randers-Pehrson
 
@@ -407,6 +407,27 @@
          (int)sizeof(unused_chunks)/5);
     #endif
 
+User limits
+
+The PNG specification allows the width and height of an image to be as
+large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
+Since very few applications really need to process such large images,
+we have imposed an arbitrary 1-million limit on rows and columns.
+Larger images will be rejected immediately with a png_error() call. If
+you wish to override this limit, you can use
+
+   png_set_user_limits(png_ptr, width_max, height_max);
+
+to set your own limits, or use width_max = height_max = 0x7fffffffL
+to allow all valid dimensions (libpng may reject some very large images
+anyway because of potential buffer overflow conditions).
+
+You should put this statement after you create the PNG structure and
+before calling png_read_info(), png_read_png(), or png_process_data().
+If you need to retrieve the limits that are being applied, use
+
+   width_max = png_get_user_width_max(png_ptr);
+   height_max = png_get_user_height_max(png_ptr);
 
 The high-level read interface
 
@@ -850,9 +871,6 @@
 
 As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
 added.  It expands the sample depth without changing tRNS to alpha.
-At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it
-will be removed from a future version.
-
 
 PNG can have files with 16 bits per channel.  If you only can handle
 8 bits per channel, this will strip the pixels down to 8 bit.
@@ -2069,7 +2087,12 @@
     PNG_TRANSFORM_INVERT_ALPHA  Change alpha from opacity
                                 to transparency
     PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples
-    PNG_TRANSFORM_STRIP_FILLER  Strip out filler bytes.
+    PNG_TRANSFORM_STRIP_FILLER        Strip out filler
+                                      bytes (deprecated).
+    PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading
+                                      filler bytes
+    PNG_TRANSFORM_STRIP_FILLER_AFTER  Strip out trailing
+                                      filler bytes
 
 If you have valid image data in the info structure (you can use
 png_set_rows() to put image data in the info structure), simply do this:
@@ -2476,9 +2499,15 @@
         png_bytep data, png_size_t length);
     void user_flush_data(png_structp png_ptr);
 
+The user_read_data() function is responsible for detecting and
+handling end-of-data errors.
+
 Supplying NULL for the read, write, or flush functions sets them back
-to using the default C stream functions.  It is an error to read from
-a write stream, and vice versa.
+to using the default C stream functions, which expect the io_ptr to
+point to a standard *FILE structure.  It is probably a mistake
+to use NULL for one of write_data_fn and output_flush_fn but not both
+of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined.
+It is an error to read from a write stream, and vice versa.
 
 Error handling in libpng is done through png_error() and png_warning().
 Errors handled through png_error() are fatal, meaning that png_error()
@@ -2583,11 +2612,12 @@
 
 Configuring for compiler xxx:
 
-All includes for libpng are in pngconf.h.  If you need to add/change/delete
-an include, this is the place to do it.  The includes that are not
-needed outside libpng are protected by the PNG_INTERNAL definition,
-which is only defined for those routines inside libpng itself.  The
-files in libpng proper only include png.h, which includes pngconf.h.
+All includes for libpng are in pngconf.h.  If you need to add, change
+or delete an include, this is the place to do it.
+The includes that are not needed outside libpng are protected by the
+PNG_INTERNAL definition, which is only defined for those routines inside
+libpng itself.  The files in libpng proper only include png.h, which
+includes pngconf.h.
 
 Configuring zlib:
 
@@ -2778,7 +2808,7 @@
 having level = 0 will be printed.  There aren't any such statements in
 this version of libpng, but if you insert some they will be printed.
 
-VII.  MNG support
+VI.  MNG support
 
 The MNG specification (available at http://www.libpng.org/pub/mng) allows
 certain extensions to PNG for PNG images that are embedded in MNG datastreams.
@@ -2803,7 +2833,7 @@
 them.  You may wish to consider using libmng (available at
 http://www.libmng.com) instead.
 
-VIII.  Changes to Libpng from version 0.88
+VII.  Changes to Libpng from version 0.88
 
 It should be noted that versions of libpng later than 0.96 are not
 distributed by the original libpng author, Guy Schalnat, nor by
@@ -2852,15 +2882,15 @@
 
    png_uint_32 application_vn = PNG_LIBPNG_VER;
 
-IX. Y2K Compliance in libpng
+VIII. Y2K Compliance in libpng
 
-February 28, 2009
+March 21, 2009
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.2.36beta01 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.36beta02 are Y2K compliant.  It is my belief that earlier
 versions were also Y2K compliant.
 
 Libpng only has three year fields.  One is a 2-byte unsigned integer that
diff --git a/libpng.3 b/libpng.3
index a32a31f..9141d04 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "February 28, 2009"
+.TH LIBPNG 3 "March 21, 2009"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.36beta01
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.36beta02
 .SH SYNOPSIS
 \fI\fB
 
@@ -821,7 +821,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.2.36beta01 - February 28, 2009
+ libpng version 1.2.36beta02 - March 21, 2009
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2009 Glenn Randers-Pehrson
@@ -830,7 +830,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.2.36beta01 - February 28, 2009
+ libpng versions 0.97, January 1998, through 1.2.36beta02 - March 21, 2009
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2008 Glenn Randers-Pehrson
 
@@ -1228,6 +1228,27 @@
          (int)sizeof(unused_chunks)/5);
     #endif
 
+.SS User limits
+
+The PNG specification allows the width and height of an image to be as
+large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
+Since very few applications really need to process such large images,
+we have imposed an arbitrary 1-million limit on rows and columns.
+Larger images will be rejected immediately with a png_error() call. If
+you wish to override this limit, you can use
+
+   png_set_user_limits(png_ptr, width_max, height_max);
+
+to set your own limits, or use width_max = height_max = 0x7fffffffL
+to allow all valid dimensions (libpng may reject some very large images
+anyway because of potential buffer overflow conditions).
+
+You should put this statement after you create the PNG structure and
+before calling png_read_info(), png_read_png(), or png_process_data().
+If you need to retrieve the limits that are being applied, use
+
+   width_max = png_get_user_width_max(png_ptr);
+   height_max = png_get_user_height_max(png_ptr);
 
 .SS The high-level read interface
 
@@ -1671,9 +1692,6 @@
 
 As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
 added.  It expands the sample depth without changing tRNS to alpha.
-At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it
-will be removed from a future version.
-
 
 PNG can have files with 16 bits per channel.  If you only can handle
 8 bits per channel, this will strip the pixels down to 8 bit.
@@ -2890,7 +2908,12 @@
     PNG_TRANSFORM_INVERT_ALPHA  Change alpha from opacity
                                 to transparency
     PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples
-    PNG_TRANSFORM_STRIP_FILLER  Strip out filler bytes.
+    PNG_TRANSFORM_STRIP_FILLER        Strip out filler
+                                      bytes (deprecated).
+    PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading
+                                      filler bytes
+    PNG_TRANSFORM_STRIP_FILLER_AFTER  Strip out trailing
+                                      filler bytes
 
 If you have valid image data in the info structure (you can use
 png_set_rows() to put image data in the info structure), simply do this:
@@ -3297,9 +3320,15 @@
         png_bytep data, png_size_t length);
     void user_flush_data(png_structp png_ptr);
 
+The user_read_data() function is responsible for detecting and
+handling end-of-data errors.
+
 Supplying NULL for the read, write, or flush functions sets them back
-to using the default C stream functions.  It is an error to read from
-a write stream, and vice versa.
+to using the default C stream functions, which expect the io_ptr to
+point to a standard *FILE structure.  It is probably a mistake
+to use NULL for one of write_data_fn and output_flush_fn but not both
+of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined.
+It is an error to read from a write stream, and vice versa.
 
 Error handling in libpng is done through png_error() and png_warning().
 Errors handled through png_error() are fatal, meaning that png_error()
@@ -3404,11 +3433,12 @@
 
 .SS Configuring for compiler xxx:
 
-All includes for libpng are in pngconf.h.  If you need to add/change/delete
-an include, this is the place to do it.  The includes that are not
-needed outside libpng are protected by the PNG_INTERNAL definition,
-which is only defined for those routines inside libpng itself.  The
-files in libpng proper only include png.h, which includes pngconf.h.
+All includes for libpng are in pngconf.h.  If you need to add, change
+or delete an include, this is the place to do it.
+The includes that are not needed outside libpng are protected by the
+PNG_INTERNAL definition, which is only defined for those routines inside
+libpng itself.  The files in libpng proper only include png.h, which
+includes pngconf.h.
 
 .SS Configuring zlib:
 
@@ -3599,7 +3629,7 @@
 having level = 0 will be printed.  There aren't any such statements in
 this version of libpng, but if you insert some they will be printed.
 
-.SH VII.  MNG support
+.SH VI.  MNG support
 
 The MNG specification (available at http://www.libpng.org/pub/mng) allows
 certain extensions to PNG for PNG images that are embedded in MNG datastreams.
@@ -3624,7 +3654,7 @@
 them.  You may wish to consider using libmng (available at
 http://www.libmng.com) instead.
 
-.SH VIII.  Changes to Libpng from version 0.88
+.SH VII.  Changes to Libpng from version 0.88
 
 It should be noted that versions of libpng later than 0.96 are not
 distributed by the original libpng author, Guy Schalnat, nor by
@@ -3673,15 +3703,15 @@
 
    png_uint_32 application_vn = PNG_LIBPNG_VER;
 
-.SH IX. Y2K Compliance in libpng
+.SH VIII. Y2K Compliance in libpng
 
-February 28, 2009
+March 21, 2009
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.2.36beta01 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.36beta02 are Y2K compliant.  It is my belief that earlier
 versions were also Y2K compliant.
 
 Libpng only has three year fields.  One is a 2-byte unsigned integer that
@@ -3943,7 +3973,7 @@
  1.2.35rc01-02       13    10235  12.so.0.35[.0]
  1.0.43              10    10043  10.so.0.43[.0]
  1.2.35              13    10235  12.so.0.35[.0]
- 1.2.36beta01        13    10236  12.so.0.36[.0]
+ 1.2.36beta01-02     13    10236  12.so.0.36[.0]
 
 Henceforth the source version will match the shared-library minor
 and patch numbers; the shared-library major version number will be
@@ -3999,7 +4029,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.2.36beta01 - February 28, 2009:
+Libpng version 1.2.36beta02 - March 21, 2009:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
 
@@ -4020,7 +4050,7 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.2.6, August 15, 2004, through 1.2.36beta01, February 28, 2009, are
+libpng versions 1.2.6, August 15, 2004, through 1.2.36beta02, March 21, 2009, are
 Copyright (c) 2004,2006-2008 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
@@ -4119,7 +4149,7 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-February 28, 2009
+March 21, 2009
 
 .\" end of man page
 
diff --git a/libpngpf.3 b/libpngpf.3
index 04daa14..281fd01 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "February 28, 2009"
+.TH LIBPNGPF 3 "March 21, 2009"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.36beta01
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.36beta02
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
diff --git a/png.5 b/png.5
index 1a4b4b5..00e2a48 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "February 28, 2009"
+.TH PNG 5 "March 21, 2009"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index aa50988..3392cf7 100644
--- a/png.c
+++ b/png.c
@@ -13,7 +13,7 @@
 #include "png.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_36beta01 Your_png_h_is_not_version_1_2_36beta01;
+typedef version_1_2_36beta02 Your_png_h_is_not_version_1_2_36beta02;
 
 /* Version information for C files.  This had better match the version
  * string defined in png.h.  */
@@ -694,7 +694,7 @@
 png_get_copyright(png_structp png_ptr)
 {
    png_ptr = png_ptr;  /* silence compiler warning about unused png_ptr */
-   return ((png_charp) "\n libpng version 1.2.36beta01 - February 28, 2009\n\
+   return ((png_charp) "\n libpng version 1.2.36beta02 - March 21, 2009\n\
    Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\
    Copyright (c) 1996-1997 Andreas Dilger\n\
    Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
@@ -800,6 +800,7 @@
 /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
 #if defined(PNG_cHRM_SUPPORTED)
 #if !defined(PNG_NO_CHECK_cHRM)
+
 /*
  Multiply two 32-bit numbers, V1 and V2, using 32-bit
  arithmetic, to produce a 64 bit result in the HI/LO words.
diff --git a/png.h b/png.h
index c1bb920..53fa6f0 100644
--- a/png.h
+++ b/png.h
@@ -1,6 +1,6 @@
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.2.36beta01 - February 28, 2009
+ * libpng version 1.2.36beta02 - March 21, 2009
  * Copyright (c) 1998-2009 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.)
@@ -8,7 +8,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.2.36beta01 - February 28, 2009: Glenn
+ *  libpng versions 0.97, January 1998, through 1.2.36beta02 - March 21, 2009: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -222,7 +222,7 @@
  *    1.2.35rc01-02           13    10235  12.so.0.35[.0]
  *    1.0.43                  10    10043  10.so.0.43[.0]
  *    1.2.35                  13    10235  12.so.0.35[.0]
- *    1.2.36beta01            13    10236  12.so.0.36[.0]
+ *    1.2.36beta01-02         13    10236  12.so.0.36[.0]
  *
  *    Henceforth the source version will match the shared-library major
  *    and minor numbers; the shared-library major version number will be
@@ -252,7 +252,7 @@
  * If you modify libpng you may insert additional notices immediately following
  * this sentence.
  *
- * libpng versions 1.2.6, August 15, 2004, through 1.2.36beta01, February 28, 2009, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.2.36beta02, March 21, 2009, are
  * Copyright (c) 2004, 2006-2008 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:
@@ -364,13 +364,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    February 28, 2009
+ *    March 21, 2009
  *
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
  *
  *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.2.36beta01 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.2.36beta02 are Y2K compliant.  It is my belief that earlier
  *    versions were also Y2K compliant.
  *
  *    Libpng only has three year fields.  One is a 2-byte unsigned integer
@@ -426,9 +426,9 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.2.36beta01"
+#define PNG_LIBPNG_VER_STRING "1.2.36beta02"
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.2.36beta01 - February 28, 2009\n"
+   " libpng version 1.2.36beta02 - March 21, 2009\n"
 
 #define PNG_LIBPNG_VER_SONUM   0
 #define PNG_LIBPNG_VER_DLLNUM  13
@@ -440,7 +440,7 @@
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
 
-#define PNG_LIBPNG_VER_BUILD  01
+#define PNG_LIBPNG_VER_BUILD  02
 
 /* Release Status */
 #define PNG_LIBPNG_BUILD_ALPHA    1
@@ -1488,7 +1488,7 @@
 /* This triggers a compiler error in png.c, if png.c and png.h
  * do not agree upon the version number.
  */
-typedef png_structp version_1_2_36beta01;
+typedef png_structp version_1_2_36beta02;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -1988,6 +1988,11 @@
  * If buffered output is not used, then output_flush_fn can be set to NULL.
  * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
  * output_flush_fn will be ignored (and thus can be NULL).
+ * It is probably a mistake to use NULL for output_flush_fn if
+ * write_data_fn is not also NULL unless you have built libpng with
+ * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
+ * default flush function, which uses the standard *FILE structure, will
+ * be used.
  */
 extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
    png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
diff --git a/pngconf.h b/pngconf.h
index 2bb5dab..ab152b4 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.2.36beta01 - February 28, 2009
+ * libpng version 1.2.36beta02 - March 21, 2009
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2009 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -800,7 +800,6 @@
 #  define PNG_USER_HEIGHT_MAX 1000000L
 #endif
 
-
 /* Added at libpng-1.2.34 and 1.4.0 */
 #ifndef PNG_STRING_NEWLINE
 #define PNG_STRING_NEWLINE "\n"
@@ -1439,7 +1438,6 @@
 #  define NOCHECK 0
 #  define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
 #  define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
-#  define png_fileno  _fileno
 #  define png_snprintf _fsnprintf   /* Added to v 1.2.19 */
 #  define png_strlen  _fstrlen
 #  define png_memcmp  _fmemcmp    /* SJT: added */
@@ -1448,11 +1446,6 @@
 #else /* use the usual functions */
 #  define CVT_PTR(ptr)         (ptr)
 #  define CVT_PTR_NOCHECK(ptr) (ptr)
-#  ifdef _MSC_VER
-#    define png_fileno  _fileno  /* Added to v 1.2.36 */
-#  else
-#    define png_fileno  fileno
-#  endif
 #  ifndef PNG_NO_SNPRINTF
 #    ifdef _MSC_VER
 #      define png_snprintf _snprintf   /* Added to v 1.2.19 */
@@ -1474,7 +1467,6 @@
 #    define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
         sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
 #  endif
-#  define png_fileno  fileno  /* Added to v 1.2.36 */
 #  define png_strlen  strlen
 #  define png_memcmp  memcmp      /* SJT: added */
 #  define png_memcpy  memcpy
diff --git a/pngerror.c b/pngerror.c
index 7652171..901dee5 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * Last changed in libpng 1.2.34 [December 18, 2008]
+ * Last changed in libpng 1.2.36 [March 21, 2009]
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -44,7 +44,7 @@
      {
        if (*error_message == '#')
        {
-         /* Strip "#nnnn " from beginning of error message. */
+           /* Strip "#nnnn " from beginning of error message. */
            int offset;
            for (offset = 1; offset<15; offset++)
               if (error_message[offset] == ' ')
@@ -217,7 +217,7 @@
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
    if (*error_message == '#')
    {
-     /* Strip "#nnnn " from beginning of warning message. */
+     /* Strip "#nnnn " from beginning of error message. */
      int offset;
      char error_number[16];
      for (offset = 0; offset<15; offset++)
@@ -229,15 +229,21 @@
      if ((offset > 1) && (offset < 15))
      {
        error_number[offset - 1] = '\0';
-       fprintf(stderr, "libpng error no. %s: %s\n", error_number,
-          error_message + offset + 1);
+       fprintf(stderr, "libpng error no. %s: %s",
+          error_number, error_message + offset + 1);
+       fprintf(stderr, PNG_STRING_NEWLINE);
      }
      else
-       fprintf(stderr, "libpng error: %s, offset=%d\n", error_message, offset);
+       fprintf(stderr, "libpng error: %s, offset=%d",
+          error_message, offset);
+       fprintf(stderr, PNG_STRING_NEWLINE);
    }
    else
 #endif
-   fprintf(stderr, "libpng error: %s\n", error_message);
+   {
+      fprintf(stderr, "libpng error: %s", error_message);
+      fprintf(stderr, PNG_STRING_NEWLINE);
+   }
 #endif
 
 #ifdef PNG_SETJMP_SUPPORTED
@@ -285,15 +291,23 @@
      if ((offset > 1) && (offset < 15))
      {
        warning_number[offset + 1] = '\0';
-       fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
-          warning_message + offset);
+       fprintf(stderr, "libpng warning no. %s: %s",
+          warning_number, warning_message + offset);
+       fprintf(stderr, PNG_STRING_NEWLINE);
      }
      else
-       fprintf(stderr, "libpng warning: %s\n", warning_message);
+     {
+       fprintf(stderr, "libpng warning: %s",
+          warning_message);
+       fprintf(stderr, PNG_STRING_NEWLINE);
+     }
    }
    else
 #  endif
-     fprintf(stderr, "libpng warning: %s\n", warning_message);
+   {
+     fprintf(stderr, "libpng warning: %s", warning_message);
+     fprintf(stderr, PNG_STRING_NEWLINE);
+   }
 #else
    warning_message = warning_message; /* make compiler happy */
 #endif
diff --git a/pngmem.c b/pngmem.c
index e28476f..f3394d7 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -425,6 +425,7 @@
    need to allocate exactly 64K, so whatever you call here must
    have the ability to do that. */
 
+
 png_voidp PNGAPI
 png_malloc(png_structp png_ptr, png_uint_32 size)
 {
diff --git a/pngread.c b/pngread.c
index ace91ba..8e9c0cb 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1434,11 +1434,11 @@
    {
       info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
          info_ptr->height * png_sizeof(png_bytep));
+      png_memset(info_ptr->row_pointers, 0, info_ptr->height
+         * png_sizeof(png_bytep));
 #ifdef PNG_FREE_ME_SUPPORTED
       info_ptr->free_me |= PNG_FREE_ROWS;
 #endif
-      png_memset(info_ptr->row_pointers, 0, info_ptr->height
-         * png_sizeof(png_bytep));
       for (row = 0; row < (int)info_ptr->height; row++)
          info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
             png_get_rowbytes(png_ptr, info_ptr));
diff --git a/pngrio.c b/pngrio.c
index 66beec3..1f85fd0 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * Last changed in libpng 1.2.36 [February 28, 2009]
+ * Last changed in libpng 1.2.36 [March 21, 2009]
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngrtran.c b/pngrtran.c
index a916f54..d7dd8e7 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -455,10 +455,8 @@
       int num_green = (1 << PNG_DITHER_GREEN_BITS);
       int num_blue = (1 << PNG_DITHER_BLUE_BITS);
       png_size_t num_entries = ((png_size_t)1 << total_bits);
-
       png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
          (png_uint_32)(num_entries * png_sizeof(png_byte)));
-
       png_memset(png_ptr->palette_lookup, 0, num_entries *
          png_sizeof(png_byte));
 
@@ -4125,14 +4123,13 @@
 
      png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
         (png_uint_32)(num * png_sizeof(png_uint_16p)));
+     png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p)); 
 
      if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
      {
         double fin, fout;
         png_uint_32 last, max;
 
-        png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p)); 
-
         for (i = 0; i < num; i++)
         {
            png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
@@ -4187,7 +4184,6 @@
 
         png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
            (png_uint_32)(num * png_sizeof(png_uint_16p )));
-
         png_memset(png_ptr->gamma_16_to_1, 0, num * png_sizeof(png_uint_16p)); 
 
         for (i = 0; i < num; i++)
@@ -4212,7 +4208,6 @@
 
         png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
            (png_uint_32)(num * png_sizeof(png_uint_16p)));
-
         png_memset(png_ptr->gamma_16_from_1, 0,
            num * png_sizeof(png_uint_16p)); 
 
diff --git a/pngrutil.c b/pngrutil.c
index 5fafde6..24462a0 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,9 +1,9 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * Last changed in libpng 1.2.34 [December 18, 2008]
+ * Last changed in libpng 1.2.36 [March 21, 2009]
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2008 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2009 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.)
  *
@@ -3187,9 +3187,11 @@
    if (row_bytes + 64 > png_ptr->old_big_row_buf_size)
    {
      png_free(png_ptr, png_ptr->big_row_buf);
-     png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
-     png_ptr->row_buf = png_ptr->big_row_buf+32;
-     png_ptr->old_big_row_buf_size = row_bytes+64;
+      png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 64);
+     if (png_ptr->interlaced)
+       png_memset(png_ptr->big_row_buf, 0, png_ptr->rowbytes + 64);
+     png_ptr->row_buf = png_ptr->big_row_buf + 32;
+     png_ptr->old_big_row_buf_size = row_bytes + 64;
    }
 
 #ifdef PNG_MAX_MALLOC_64K
diff --git a/pngset.c b/pngset.c
index 9e12b0d..daa64d8 100644
--- a/pngset.c
+++ b/pngset.c
@@ -383,10 +383,6 @@
       return;
    }
 
-#ifdef PNG_FREE_ME_SUPPORTED
-   info_ptr->free_me |= PNG_FREE_PCAL;
-#endif
-
    png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));
 
    for (i = 0; i < nparams; i++)
@@ -404,6 +400,9 @@
    }
 
    info_ptr->valid |= PNG_INFO_pCAL;
+#ifdef PNG_FREE_ME_SUPPORTED
+   info_ptr->free_me |= PNG_FREE_PCAL;
+#endif
 }
 #endif
 
@@ -961,7 +960,6 @@
 
     png_memcpy(np, info_ptr->splt_palettes,
            info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
-
     png_free(png_ptr, info_ptr->splt_palettes);
     info_ptr->splt_palettes=NULL;
 
diff --git a/pngtest.c b/pngtest.c
index 6b7537d..28c2ff9 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,9 +1,9 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * Last changed in libpng 1.2.32 [September 18, 2008]
+ * Last changed in libpng 1.2.36 [March 21, 2009]
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2008 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2009 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.)
  *
@@ -362,12 +362,8 @@
 static void
 pngtest_flush(png_structp png_ptr)
 {
-#if !defined(_WIN32_WCE)
-   png_FILE_p io_ptr;
-   io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
-   if (io_ptr != NULL)
-      fflush(io_ptr);
-#endif
+   /* Do nothing; fflush() is said to be just a waste of energy. */
+   png_ptr = png_ptr;  /* stifle compiler warning */
 }
 #endif
 
@@ -1685,4 +1681,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_36beta01 your_png_h_is_not_version_1_2_36beta01;
+typedef version_1_2_36beta02 your_png_h_is_not_version_1_2_36beta02;
diff --git a/pngwio.c b/pngwio.c
index 1f56335..57ac491 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * Last changed in libpng 1.2.36 [February 28, 2009]
+ * Last changed in libpng 1.2.36 [March 21, 2009]
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2009 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -137,8 +137,7 @@
    if (png_ptr == NULL) return;
 #if !defined(_WIN32_WCE)
    io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
-   if (io_ptr != NULL && png_fileno(io_ptr) != -1)
-      fflush(io_ptr);
+   fflush(io_ptr);
 #endif
 }
 #endif
@@ -168,7 +167,10 @@
                    PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
                    time, output_flush_fn will be ignored, although it must be
                    supplied for compatibility.  May be NULL, in which case
-                   libpng's default function will be used. */
+                   libpng's default function will be used, if
+                   PNG_WRITE_FLUSH_SUPPORTED is defined.  This is not
+                   a good idea if io_ptr does not point to a standard
+                   *FILE structure. */
 void PNGAPI
 png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
diff --git a/pngwutil.c b/pngwutil.c
index 957e266..47f3516 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1759,9 +1759,9 @@
    if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
    {
      /* set up previous row buffer */
-      png_ptr->prev_row = (png_bytep)png_malloc(png_ptr,
+     png_ptr->prev_row = (png_bytep)png_malloc(png_ptr,
         (png_uint_32)buf_size);
-      png_memset(png_ptr->prev_row, 0, buf_size);
+     png_memset(png_ptr->prev_row, 0, buf_size);
 
       if (png_ptr->do_filter & PNG_FILTER_UP)
       {
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 808c5a3..31e3e24 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -169,7 +169,7 @@
 
 # SET UP LINKS
 set_target_properties(${PNG_LIB_NAME} PROPERTIES
-#    VERSION 0.${PNGLIB_RELEASE}.1.2.36beta01
+#    VERSION 0.${PNGLIB_RELEASE}.1.2.36beta02
      VERSION 0.${PNGLIB_RELEASE}.0
      SOVERSION 0
      CLEAN_DIRECT_OUTPUT 1)
diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in
index 2d4ae71..bcf4d1c 100755
--- a/scripts/libpng-config-head.in
+++ b/scripts/libpng-config-head.in
@@ -8,7 +8,7 @@
 
 # Modeled after libxml-config.
 
-version=1.2.36beta01
+version=1.2.36beta02
 prefix=""
 libdir=""
 libs=""
diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in
index 6852830..fbea96f 100644
--- a/scripts/libpng.pc.in
+++ b/scripts/libpng.pc.in
@@ -5,6 +5,6 @@
 
 Name: libpng
 Description: Loads and saves PNG files
-Version: 1.2.36beta01
+Version: 1.2.36beta02
 Libs: -L${libdir} -lpng12
 Cflags: -I${includedir}
diff --git a/scripts/makefile.32sunu b/scripts/makefile.32sunu
index 7226df0..d514549 100644
--- a/scripts/makefile.32sunu
+++ b/scripts/makefile.32sunu
@@ -8,7 +8,7 @@
 # Library name:
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.64sunu b/scripts/makefile.64sunu
index 7d82d7d..e83641b 100644
--- a/scripts/makefile.64sunu
+++ b/scripts/makefile.64sunu
@@ -8,7 +8,7 @@
 # Library name:
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.aix b/scripts/makefile.aix
index d2110a1..5b24d7b 100644
--- a/scripts/makefile.aix
+++ b/scripts/makefile.aix
@@ -20,7 +20,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 prefix=/usr/local
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index f47eedb..42cf548 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -8,7 +8,7 @@
 # Library name:
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin
index 1363b64..b996ddc 100644
--- a/scripts/makefile.cygwin
+++ b/scripts/makefile.cygwin
@@ -74,7 +74,7 @@
 LIBNAME = libpng12
 PNGMAJ = 0
 CYGDLL = 12
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 SHAREDLIB=cygpng$(CYGDLL).dll
diff --git a/scripts/makefile.darwin b/scripts/makefile.darwin
index 527c51b..a827d4f 100644
--- a/scripts/makefile.darwin
+++ b/scripts/makefile.darwin
@@ -19,7 +19,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 12
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 17f9ba2..709df76 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -5,7 +5,7 @@
 
 # Library name:
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/makefile.elf b/scripts/makefile.elf
index 3d34e8f..2cf4288 100644
--- a/scripts/makefile.elf
+++ b/scripts/makefile.elf
@@ -13,7 +13,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index 9931d41..d9af7b6 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -14,7 +14,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.hp64 b/scripts/makefile.hp64
index 602bb0e..0f54db5 100644
--- a/scripts/makefile.hp64
+++ b/scripts/makefile.hp64
@@ -18,7 +18,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc
index 829c9fb..cf2f41f 100644
--- a/scripts/makefile.hpgcc
+++ b/scripts/makefile.hpgcc
@@ -8,7 +8,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index 52bb90c..b9ac9cc 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -18,7 +18,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 61f7792..c1f78aa 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -7,7 +7,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.mingw b/scripts/makefile.mingw
index 280f18a..a03d25a 100644
--- a/scripts/makefile.mingw
+++ b/scripts/makefile.mingw
@@ -74,7 +74,7 @@
 LIBNAME = libpng12
 PNGMAJ = 0
 MINGDLL = 12
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 SHAREDLIB=libpng$(MINGDLL).dll
diff --git a/scripts/makefile.ne12bsd b/scripts/makefile.ne12bsd
index a454cf2..1db537e 100644
--- a/scripts/makefile.ne12bsd
+++ b/scripts/makefile.ne12bsd
@@ -14,7 +14,7 @@
 
 LIB=	png12
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.2.36beta01
+SHLIB_MINOR=	1.2.36beta02
 SRCS=	png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 	pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 	pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd
index 0888017..efbb15a 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -14,7 +14,7 @@
 
 LIB=	png
 SHLIB_MAJOR=	3
-SHLIB_MINOR=	1.2.36beta01
+SHLIB_MINOR=	1.2.36beta02
 SRCS=	png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 	pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 	pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.nommx b/scripts/makefile.nommx
index c2dd33b..896d01f 100644
--- a/scripts/makefile.nommx
+++ b/scripts/makefile.nommx
@@ -7,7 +7,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.openbsd b/scripts/makefile.openbsd
index 39d80e2..3dec2f2 100644
--- a/scripts/makefile.openbsd
+++ b/scripts/makefile.openbsd
@@ -8,7 +8,7 @@
 MANDIR= ${PREFIX}/man/cat
 
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.2.36beta01
+SHLIB_MINOR=	1.2.36beta02
 
 LIB=	png
 SRCS=	png.c pngerror.c pngget.c pngmem.c pngpread.c \
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index 92e17d6..7610d98 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -9,7 +9,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index 76e7884..7c132d4 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -6,7 +6,7 @@
 # Library name:
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index c07754f..05e2392 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -6,7 +6,7 @@
 # Library name:
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.so9 b/scripts/makefile.so9
index 1f52e08..595c91c 100644
--- a/scripts/makefile.so9
+++ b/scripts/makefile.so9
@@ -8,7 +8,7 @@
 
 # Library name:
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index fa23d59..cbb72d5 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -8,7 +8,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/makefile.solaris-x86 b/scripts/makefile.solaris-x86
index 07b8b52..69c58af 100644
--- a/scripts/makefile.solaris-x86
+++ b/scripts/makefile.solaris-x86
@@ -8,7 +8,7 @@
 # Library name:
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.36beta01
+PNGMIN = 1.2.36beta02
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Shared library names:
diff --git a/scripts/pngos2.def b/scripts/pngos2.def
index 73edadd..b072353 100644
--- a/scripts/pngos2.def
+++ b/scripts/pngos2.def
@@ -2,7 +2,7 @@
 ; PNG.LIB module definition file for OS/2
 ;----------------------------------------
 
-; Version 1.2.36beta01
+; Version 1.2.36beta02
 
 LIBRARY		PNG
 DESCRIPTION	"PNG image compression library for OS/2"
diff --git a/scripts/pngw32.def b/scripts/pngw32.def
index d7c276e..9152bdd 100644
--- a/scripts/pngw32.def
+++ b/scripts/pngw32.def
@@ -5,7 +5,7 @@
 LIBRARY
 
 EXPORTS
-;Version 1.2.36beta01
+;Version 1.2.36beta02
   png_build_grayscale_palette  @1
   png_check_sig        @2
   png_chunk_error      @3