Imported from libpng-1.2.0beta2.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index 0d3986b..276d900 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.2.0beta1 - May 6, 2001
+Libpng 1.2.0beta2 - May 7, 2001
 
 This is a public release of libpng, intended for use in production codes.
 
@@ -13,6 +13,7 @@
     by default.
   Added runtime selection of MMX features.
   Added png_set_strip_error_numbers function and related macros.
+  Added a check for attempts to read or write PLTE in grayscale PNG datastreams.
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index c3cf929..57a62b3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -940,6 +940,9 @@
     by default.
   Added runtime selection of MMX features.
   Added png_set_strip_error_numbers function and related macros.
+version 1.2.0beta2 [May 7, 2001]
+  Finished merging 1.2.0beta1 with version 1.0.9
+  Added a check for attempts to read or write PLTE in grayscale PNG datastreams.
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/INSTALL b/INSTALL
index d2ad286..2c96560 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.2.0beta1 - May 6, 2001
+Installing libpng version 1.2.0beta2 - May 7, 2001
 
 Before installing libpng, you must first install zlib.  zlib
 can usually be found wherever you got libpng.  zlib can be
@@ -10,7 +10,7 @@
 version of zlib that's installed.
 
 You can rename the directories that you downloaded (they
-might be called "libpng-1.2.0beta1" or "lpng109" and "zlib-1.1.3"
+might be called "libpng-1.2.0beta2" or "lpng109" and "zlib-1.1.3"
 or "zlib113") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
@@ -28,6 +28,7 @@
              pngsuite
              visupng
           projects
+             beos
              borland
              msvc
              wince
@@ -59,8 +60,8 @@
 include
 
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
- makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.2.0beta1)
- makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.2.0beta1,
+ makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.2.0beta2)
+ makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.2.0beta2,
                        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
@@ -69,15 +70,17 @@
  makefile.aix      =>  AIX makefile
  makefile.cygwin   =>  Cygwin/gcc makefile
  makefile.dec      =>  DEC Alpha UNIX makefile
+ makefile.hpgcc    =>  HPUX makefile using gcc
  makefile.hpux     =>  HPUX (10.20 and 11.00) makefile
  makefile.ibmc     =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
  makefile.intel    =>  Intel C/C++ version 4.0 and later
  libpng.icc        =>  Project file for IBM VisualAge/C++ version 4.0 or later
  makefile.macosx   =>  MACOS X Makefile
+ makefile.netbsd   =>  NetBSD/cc makefile, uses PNGGCCRD
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
- makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng.so.2.1.2.0beta1)
+ makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng.so.2.1.2.0beta2)
  makefile.sunos    =>  Sun makefile
- makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.2.0beta1)
+ makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.2.0beta2)
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
  makefile.mips     =>  MIPS makefile
  makefile.acorn    =>  Acorn makefile
diff --git a/LICENSE b/LICENSE
index aadf18f..7a5059b 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.0.7, July 1, 2000, through 1.2.0beta1, May 6, 2001, are
+libpng versions 1.0.7, July 1, 2000, through 1.2.0beta2, May 7, 2001, are
 Copyright (c) 2000 Glenn Randers-Pehrson
 and are distributed according to the same disclaimer and license as libpng-1.0.6
 with the following individuals added to the list of Contributing Authors
@@ -99,4 +99,4 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-May 6, 2001
+May 7, 2001
diff --git a/README b/README
index 44c77c8..e510816 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.2.0beta1 - May 6, 2001 (shared library 2.1)
+README for libpng 1.2.0beta2 - May 7, 2001 (shared library 2.1)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -172,6 +172,7 @@
        pngsuite     =>  Test images
        visupng      =>  Contains a MSVC workspace for VisualPng
       projects      =>  Contains project files and workspaces for building DLL
+       beos             =>  Contains a Beos workspace for building libpng
        borland          =>  Contains a Borland workspace for building libpng
                             and zlib
        msvc             =>  Contains a Microsoft Visual C++ (MSVC) workspace
@@ -182,9 +183,9 @@
        descrip.mms      =>  VMS makefile for MMS or MMK
        makefile.std     =>  Generic UNIX makefile (cc, creates static libpng.a)
        makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng.so.2.1.2.0beta1)
+                            (gcc, creates libpng.so.2.1.2.0beta2)
        makefile.gcmmx   =>  Linux/ELF makefile (gcc, creates
-                            libpng.so.2.1.2.0beta1, uses assembler code
+                            libpng.so.2.1.2.0beta2, 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
@@ -193,16 +194,18 @@
        makefile.aix     =>  AIX makefile
        makefile.cygwin  =>  Cygwin/gcc makefile
        makefile.dec     =>  DEC Alpha UNIX makefile
+       makefile.hpgcc   =>  HPUX makefile using gcc
        makefile.hpux    =>  HPUX (10.20 and 11.00) makefile
        makefile.ibmc    =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
        makefile.intel   =>  Intel C/C++ version 4.0 and later
        libpng.icc       =>  Project file, IBM VisualAge/C++ 4.0 or later
        makefile.macosx  =>  MACOS X Makefile
+       makefile.netbsd  =>  NetBSD/cc makefile, uses PNGGCCRD
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
-       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng.so.2.1.2.0beta1)
+       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng.so.2.1.2.0beta2)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng.so.2.1.2.0beta1)
+                            (gcc, creates libpng.so.2.1.2.0beta2)
        makefile.sco     =>  For SCO OSr5  ELF and Unixware 7 with Native cc
        makefile.mips    =>  MIPS makefile
        makefile.acorn   =>  Acorn makefile
diff --git a/Y2KINFO b/Y2KINFO
index 174c730..bcc0a78 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      May 6, 2001
+      May 7, 2001
 
       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.0beta1 are Y2K compliant.  It is my belief that earlier
+      upward through 1.2.0beta2 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 159fbad..9d76b68 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 echo "
-  There is no \"configure\" script for Libpng-1.2.0beta1.  Instead, please
+  There is no \"configure\" script for Libpng-1.2.0beta2.  Instead, please
   copy the appropriate makefile for your system from the \"scripts\"
   directory.  Read the INSTALL file for more details.
 "
diff --git a/example.c b/example.c
index 1e953c8..f0fe688 100644
--- a/example.c
+++ b/example.c
@@ -338,7 +338,8 @@
 
    for (row = 0; row < height; row++)
    {
-      row_pointers[row] = malloc(png_get_rowbytes(png_ptr, info_ptr));
+      row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
+         info_ptr));
    }
 
    /* Now it's time to read the image.  One of these methods is REQUIRED */
@@ -494,7 +495,7 @@
  * png_progressive_combine_row() passing in the row and the
  * old row.  You can call this function for NULL rows (it will
  * just return) and for non-interlaced images (it just does the
- * memcpy for you) if it will make the code easier.  Thus, you
+ * png_memcpy for you) if it will make the code easier.  Thus, you
  * can just do this for all cases:
  */
 
@@ -603,7 +604,8 @@
       PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
 
    /* set the palette if there is one.  REQUIRED for indexed-color images */
-   palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * sizeof (png_color));
+   palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
+             * sizeof (png_color));
    /* ... set palette colors ... */
    png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
    /* You must not free palette here, because png_set_PLTE only makes a link to
diff --git a/libpng.3 b/libpng.3
index 88a3758..1e546c3 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "May 6, 2001"
+.TH LIBPNG 3 "May 7, 2001"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.0beta1
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.0beta2
 .SH SYNOPSIS
 \fI\fB
 
@@ -781,7 +781,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.2.0beta1 - May 6, 2001
+ libpng version 1.2.0beta2 - May 7, 2001
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998-2001 Glenn Randers-Pehrson
@@ -3600,13 +3600,13 @@
 
 .SH IX. Y2K Compliance in libpng
 
-May 6, 2001
+May 7, 2001
 
 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.0beta1 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.0beta2 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
@@ -3777,7 +3777,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.2.0beta1 - May 6, 2001:
+Libpng version 1.2.0beta2 - May 7, 2001:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
 
@@ -3794,7 +3794,7 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.0.7, July 1, 2000, through  1.2.0beta1, May 6, 2001, are
+libpng versions 1.0.7, July 1, 2000, through  1.2.0beta2, May 7, 2001, are
 Copyright (c) 2000-2001 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.0.6
 with the following individuals added to the list of Contributing Authors
@@ -3886,7 +3886,7 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-May 6, 2001
+May 7, 2001
 
 .\" end of man page
 
diff --git a/libpng.txt b/libpng.txt
index 7719a26..f40801e 100644
--- a/libpng.txt
+++ b/libpng.txt
@@ -1,6 +1,6 @@
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.2.0beta1 - May 6, 2001
+ libpng version 1.2.0beta2 - May 7, 2001
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998-2001 Glenn Randers-Pehrson
@@ -2819,13 +2819,13 @@
 
 IX. Y2K Compliance in libpng
 
-May 6, 2001
+May 7, 2001
 
 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.0beta1 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.0beta2 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/libpngpf.3 b/libpngpf.3
index 67beb26..f365fbd 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "May 6, 2001"
+.TH LIBPNGPF 3 "May 7, 2001"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.0beta1
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.0beta2
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
diff --git a/png.5 b/png.5
index a1fda65..5c8912a 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "May 6, 2001"
+.TH PNG 5 "May 7, 2001"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index 3010f24..de44a55 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.2.0beta1 - May 6, 2001
+ * libpng version 1.2.0beta2 - May 7, 2001
  * Copyright (c) 1998-2001 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.)
@@ -13,14 +13,14 @@
 #include "png.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_0beta1 Your_png_h_is_not_version_1_2_0beta1;
+typedef version_1_2_0beta2 Your_png_h_is_not_version_1_2_0beta2;
 
 /* Version information for C files.  This had better match the version
  * string defined in png.h.  */
 
 #ifdef PNG_USE_GLOBAL_ARRAYS
 /* png_libpng_ver was changed to a function in version 1.0.5c */
-const char png_libpng_ver[18] = "1.2.0beta1";
+const char png_libpng_ver[18] = "1.2.0beta2";
 
 /* png_sig was changed to a function in version 1.0.5c */
 /* Place to hold the signature string for a PNG file. */
@@ -627,7 +627,7 @@
 png_get_copyright(png_structp png_ptr)
 {
    if (png_ptr != NULL || png_ptr == NULL)  /* silence compiler warning */
-   return ((png_charp) "\n libpng version 1.2.0beta1 - May 6, 2001\n\
+   return ((png_charp) "\n libpng version 1.2.0beta2 - May 7, 2001\n\
    Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\
    Copyright (c) 1996, 1997 Andreas Dilger\n\
    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n");
@@ -645,8 +645,8 @@
 {
    /* Version of *.c files used when building libpng */
    if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
-      return((png_charp) "1.2.0beta1");
-   return((png_charp) "1.2.0beta1");
+      return((png_charp) "1.2.0beta2");
+   return((png_charp) "1.2.0beta2");
 }
 
 png_charp PNGAPI
diff --git a/png.h b/png.h
index 993ec20..a40ccfc 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.2.0beta1 - May 6, 2001
+ * libpng version 1.2.0beta2 - May 7, 2001
  * Copyright (c) 1998-2001 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.)
@@ -9,7 +9,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.0beta1 - May 6, 2001: Glenn
+ *  libpng versions 0.97, January 1998, through 1.2.0beta2 - May 7, 2001: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -101,7 +101,7 @@
  * If you modify libpng you may insert additional notices immediately following
  * this sentence.
  *
- * libpng versions 1.0.7, July 1, 2000, through  1.2.0beta1, May 6, 2001, are
+ * libpng versions 1.0.7, July 1, 2000, through  1.2.0beta2, May 7, 2001, are
  * Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are
  * distributed according to the same disclaimer and license as libpng-1.0.6
  * with the following individuals added to the list of Contributing Authors
@@ -206,13 +206,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    May 6, 2001
+ *    May 7, 2001
  *
  *    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.0beta1 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.2.0beta2 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
@@ -268,7 +268,7 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.2.0beta1"
+#define PNG_LIBPNG_VER_STRING "1.2.0beta2"
 
 #define PNG_LIBPNG_VER_SONUM   2
 #define PNG_LIBPNG_VER_DLLNUM  %DLLNUM%
@@ -280,7 +280,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  1
+#define PNG_LIBPNG_VER_BUILD  2
 
 #define PNG_LIBPNG_BUILD_ALPHA    1
 #define PNG_LIBPNG_BUILD_BETA     2
@@ -1195,9 +1195,9 @@
 
 
 /* This prevents a compiler error in png_get_copyright() in png.c if png.c
-and png.h are both at * version 1.2.0beta1
+and png.h are both at * version 1.2.0beta2
  */
-typedef png_structp version_1_2_0beta1;
+typedef png_structp version_1_2_0beta2;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -2310,7 +2310,7 @@
 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
 
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.2.0beta1 - May 6, 2001 (header)\n"
+   " libpng version 1.2.0beta2 - May 7, 2001 (header)\n"
 
 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
 /* With these routines we avoid an integer divide, which will be slower on
diff --git a/pngasmrd.h b/pngasmrd.h
index db25524..df884dc 100644
--- a/pngasmrd.h
+++ b/pngasmrd.h
@@ -1,6 +1,6 @@
 /* pngasmrd.h - assembler version of utilities to read a PNG file
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 2001 Glenn Randers-Pehrson
  *
diff --git a/pngconf.h b/pngconf.h
index 8c31158..bcac877 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,6 +1,6 @@
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngerror.c b/pngerror.c
index 98f8c7b..ea2c3a7 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -152,7 +152,7 @@
 void PNGAPI
 png_chunk_warning(png_structp png_ptr, png_const_charp message)
 {
-   char msg[16+64];
+   char msg[18+64];
    png_format_buffer(png_ptr, msg, message);
    png_warning(png_ptr, msg);
 }
diff --git a/pnggccrd.c b/pnggccrd.c
index e0ca203..242e69f 100644
--- a/pnggccrd.c
+++ b/pnggccrd.c
@@ -6,7 +6,7 @@
  *     and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
  *     for Intel's performance analysis of the MMX vs. non-MMX code.
  *
- * libpng version 1.2.0beta1 - May 6, 2001
+ * libpng version 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngget.c b/pngget.c
index df0d636..b7c3c24 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -137,7 +137,7 @@
 #if defined(PNG_pHYs_SUPPORTED)
    if (info_ptr->valid & PNG_INFO_pHYs)
    {
-       png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
+      png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
       if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
           return (0);
       else return (info_ptr->y_pixels_per_unit);
@@ -297,7 +297,7 @@
      *.00003937);
 }
 
-#if defined(PNG_READ_pHYs_SUPPORTED)
+#if defined(PNG_pHYs_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
@@ -330,7 +330,7 @@
    }
    return (retval);
 }
-#endif /* PNG_READ_pHYs_SUPPORTED */
+#endif /* PNG_pHYs_SUPPORTED */
 #endif  /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
 
 /* png_get_channels really belongs in here, too, but it's been around longer */
@@ -355,7 +355,7 @@
       return (NULL);
 }
 
-#if defined(PNG_READ_bKGD_SUPPORTED)
+#if defined(PNG_bKGD_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
    png_color_16p *background)
@@ -371,7 +371,7 @@
 }
 #endif
 
-#if defined(PNG_READ_cHRM_SUPPORTED)
+#if defined(PNG_cHRM_SUPPORTED)
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 png_uint_32 PNGAPI
 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
@@ -435,7 +435,7 @@
 #endif
 #endif
 
-#if defined(PNG_READ_gAMA_SUPPORTED)
+#if defined(PNG_gAMA_SUPPORTED)
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 png_uint_32 PNGAPI
 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
@@ -467,7 +467,7 @@
 #endif
 #endif
 
-#if defined(PNG_READ_sRGB_SUPPORTED)
+#if defined(PNG_sRGB_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
 {
@@ -482,7 +482,7 @@
 }
 #endif
 
-#if defined(PNG_READ_iCCP_SUPPORTED)
+#if defined(PNG_iCCP_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
              png_charpp name, int *compression_type,
@@ -504,7 +504,7 @@
 }
 #endif
 
-#if defined(PNG_READ_sPLT_SUPPORTED)
+#if defined(PNG_sPLT_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
              png_sPLT_tpp spalettes)
@@ -515,7 +515,7 @@
 }
 #endif
 
-#if defined(PNG_READ_hIST_SUPPORTED)
+#if defined(PNG_hIST_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
 {
@@ -576,7 +576,7 @@
    return (0);
 }
 
-#if defined(PNG_READ_oFFs_SUPPORTED)
+#if defined(PNG_oFFs_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
@@ -594,7 +594,7 @@
 }
 #endif
 
-#if defined(PNG_READ_pCAL_SUPPORTED)
+#if defined(PNG_pCAL_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
@@ -618,7 +618,7 @@
 }
 #endif
 
-#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
+#if defined(PNG_sCAL_SUPPORTED)
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 png_uint_32 PNGAPI
 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
@@ -654,7 +654,7 @@
 #endif
 #endif
 
-#if defined(PNG_READ_pHYs_SUPPORTED)
+#if defined(PNG_pHYs_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
@@ -701,7 +701,7 @@
    return (0);
 }
 
-#if defined(PNG_READ_sBIT_SUPPORTED)
+#if defined(PNG_sBIT_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
 {
@@ -716,7 +716,7 @@
 }
 #endif
 
-#if defined(PNG_READ_TEXT_SUPPORTED)
+#if defined(PNG_TEXT_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
    int *num_text)
@@ -738,7 +738,7 @@
 }
 #endif
 
-#if defined(PNG_READ_tIME_SUPPORTED)
+#if defined(PNG_tIME_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
 {
@@ -753,7 +753,7 @@
 }
 #endif
 
-#if defined(PNG_READ_tRNS_SUPPORTED)
+#if defined(PNG_tRNS_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
    png_bytep *trans, int *num_trans, png_color_16p *trans_values)
@@ -792,7 +792,7 @@
 }
 #endif
 
-#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
 png_uint_32 PNGAPI
 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
              png_unknown_chunkpp unknowns)
@@ -811,7 +811,7 @@
 }
 #endif
 
-#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+#if defined(PNG_USER_CHUNKS_SUPPORTED)
 png_voidp PNGAPI
 png_get_user_chunk_ptr(png_structp png_ptr)
 {
diff --git a/pngmem.c b/pngmem.c
index 19364c3..bff23d7 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -119,7 +119,12 @@
 
 #ifdef PNG_USER_MEM_SUPPORTED
    if(png_ptr->malloc_fn != NULL)
-       return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+   {
+       ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+       if (ret == NULL)
+          png_error(png_ptr, "Out of memory!");
+       return (ret);
+   }
    else
        return png_malloc_default(png_ptr, size);
 }
@@ -373,15 +378,18 @@
 png_voidp PNGAPI
 png_malloc(png_structp png_ptr, png_uint_32 size)
 {
-#ifndef PNG_USER_MEM_SUPPORTED
    png_voidp ret;
-#endif
    if (png_ptr == NULL || size == 0)
       return ((png_voidp)NULL);
 
 #ifdef PNG_USER_MEM_SUPPORTED
    if(png_ptr->malloc_fn != NULL)
-       return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+   {
+       ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+       if (ret == NULL)
+          png_error(png_ptr, "Out of Memory!");
+       return (ret);
+   }
    else
        return (png_malloc_default(png_ptr, size));
 }
@@ -407,9 +415,7 @@
 #endif
 
    if (ret == NULL)
-   {
       png_error(png_ptr, "Out of Memory");
-   }
 
    return (ret);
 }
diff --git a/pngpread.c b/pngpread.c
index 50b74ce..aaf6bd2 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -796,6 +796,19 @@
                   png_read_push_finish_row(png_ptr);
                }
             }
+	    if (png_ptr->pass == 4 && png_ptr->height <= 4)
+	    {
+	        for (i = 0; i < 2 && png_ptr->pass == 4; i++)
+                {
+                   png_push_have_row(png_ptr, NULL);
+                   png_read_push_finish_row(png_ptr);
+                }
+            }
+            if (png_ptr->pass == 6 && png_ptr->height <= 4)
+            {
+                png_push_have_row(png_ptr, NULL);
+                png_read_push_finish_row(png_ptr);
+            }
             break;
          }
          case 1:
@@ -982,19 +995,20 @@
 
 #if defined(PNG_READ_tEXt_SUPPORTED)
 void /* PRIVATE */
-png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
+   length)
 {
    if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
       {
          png_error(png_ptr, "Out of place tEXt");
          /* to quiet some compiler warnings */
-         info_ptr = info_ptr;
+         if(info_ptr == NULL) return;
       }
 
 #ifdef PNG_MAX_MALLOC_64K
    png_ptr->skip_length = 0;  /* This may not be necessary */
 
-   if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */
+   if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
    {
       png_warning(png_ptr, "tEXt chunk too large to fit in memory");
       png_ptr->skip_length = length - (png_uint_32)65535L;
@@ -1073,13 +1087,14 @@
 
 #if defined(PNG_READ_zTXt_SUPPORTED)
 void /* PRIVATE */
-png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
+   length)
 {
    if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
       {
          png_error(png_ptr, "Out of place zTXt");
          /* to quiet some compiler warnings */
-         info_ptr = info_ptr;
+         if(info_ptr == NULL) return;
       }
 
 #ifdef PNG_MAX_MALLOC_64K
@@ -1185,8 +1200,8 @@
             if (text == NULL)
             {
                text = (png_charp)png_malloc(png_ptr,
-                  (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out +
-                     key_size + 1));
+                  (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
+                     + key_size + 1));
                png_memcpy(text + key_size, png_ptr->zbuf,
                   png_ptr->zbuf_size - png_ptr->zstream.avail_out);
                png_memcpy(text, key, key_size);
@@ -1257,19 +1272,20 @@
 
 #if defined(PNG_READ_iTXt_SUPPORTED)
 void /* PRIVATE */
-png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
+   length)
 {
    if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
       {
          png_error(png_ptr, "Out of place iTXt");
          /* to quiet some compiler warnings */
-         info_ptr = info_ptr;
+         if(info_ptr == NULL) return;
       }
 
 #ifdef PNG_MAX_MALLOC_64K
    png_ptr->skip_length = 0;  /* This may not be necessary */
 
-   if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */
+   if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
    {
       png_warning(png_ptr, "iTXt chunk too large to fit in memory");
       png_ptr->skip_length = length - (png_uint_32)65535L;
@@ -1367,7 +1383,8 @@
  * name or a critical chunk), the chunk is (currently) silently ignored.
  */
 void /* PRIVATE */
-png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
+   length)
 {
    png_uint_32 skip=0;
    png_check_chunk_name(png_ptr, png_ptr->chunk_name);
@@ -1378,14 +1395,15 @@
       if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
            HANDLE_CHUNK_ALWAYS
 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
-           && png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
+           && png_ptr->read_user_chunk_fn == NULL
 #endif
          )
 #endif
          png_chunk_error(png_ptr, "unknown critical chunk");
 
-         /* to quiet compiler warnings about unused info_ptr */
-         info_ptr = info_ptr;
+      /* to quiet compiler warnings about unused info_ptr */
+      if (info_ptr == NULL)
+         return;
    }
 
 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
@@ -1402,12 +1420,12 @@
        }
 #endif
 
-       strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
+       png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
        chunk.data = (png_bytep)png_malloc(png_ptr, length);
        png_crc_read(png_ptr, chunk.data, length);
        chunk.size = length;
 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
-       if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
+       if(png_ptr->read_user_chunk_fn != NULL)
        {
           /* callback to user unknown chunk handler */
           if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
diff --git a/pngread.c b/pngread.c
index 1634494..904e5f0 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -53,7 +53,6 @@
    {
       return (png_structp)NULL;
    }
-
 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
    png_init_mmx_flags(png_ptr);   /* 1.2.0 addition */
 #endif
@@ -723,7 +722,7 @@
  * not called png_set_interlace_handling(), the display_row buffer will
  * be ignored, so pass NULL to it.
  *
- * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.0beta1
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.0beta2
  */
 
 void PNGAPI
@@ -772,7 +771,7 @@
  * only call this function once.  If you desire to have an image for
  * each pass of a interlaced image, use png_read_rows() instead.
  *
- * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.0beta1
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.0beta2
  */
 void PNGAPI
 png_read_image(png_structp png_ptr, png_bytepp image)
@@ -1060,7 +1059,7 @@
 }
 
 /* free all memory used by the read (old method) */
-void PNGAPI
+void /* PRIVATE */
 png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
 {
 #ifdef PNG_SETJMP_SUPPORTED
@@ -1313,7 +1312,7 @@
 
    /* Optional call to gamma correct and add the background to the palette
     * and update info structure.  REQUIRED if you are expecting libpng to
-    * update the palette for you (ie you selected such a transform above).
+    * update the palette for you (i.e., you selected such a transform above).
     */
    png_read_update_info(png_ptr, info_ptr);
 
@@ -1325,13 +1324,15 @@
    if(info_ptr->row_pointers == NULL)
    {
       info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
-                                         info_ptr->height * sizeof(png_bytep));
+         info_ptr->height * sizeof(png_bytep));
 #ifdef PNG_FREE_ME_SUPPORTED
       info_ptr->free_me |= PNG_FREE_ROWS;
 #endif
       for (row = 0; row < (int)info_ptr->height; row++)
-         info_ptr->row_pointers[row] = png_malloc(png_ptr,
+      {
+         info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
             png_get_rowbytes(png_ptr, info_ptr));
+      }
    }
 
    png_read_image(png_ptr, info_ptr->row_pointers);
@@ -1340,7 +1341,7 @@
    /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
    png_read_end(png_ptr, info_ptr);
 
-   if(transforms == 0 || params == (voidp)NULL)
+   if(transforms == 0 || params == NULL)
       /* quiet compiler warnings */ return;
 
 }
diff --git a/pngrio.c b/pngrio.c
index dd62580..d5ef36a 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngrtran.c b/pngrtran.c
index 279e81c..929b5bb 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngrutil.c b/pngrutil.c
index dd08ff6..6410c54 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -30,7 +30,7 @@
       MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len);
       result = wcstod(str, &end);
       len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL);
-      *endptr = (char *)nptr + (strlen(nptr) - len + 1);
+      *endptr = (char *)nptr + (png_strlen(nptr) - len + 1);
       free(str);
    }
    return result;
@@ -220,7 +220,7 @@
                    png_ptr->zbuf_size - png_ptr->zstream.avail_out;
                text = (png_charp)png_malloc(png_ptr, text_size + 1);
                png_memcpy(text + prefix_size, png_ptr->zbuf,
-                          text_size - prefix_size);
+                    text_size - prefix_size);
                png_memcpy(text, chunkdata, prefix_size);
                *(text + text_size) = 0x00;
             }
@@ -332,59 +332,6 @@
    filter_type = buf[11];
    interlace_type = buf[12];
 
-   /* check for width and height valid values */
-   if (width == 0 || width > PNG_MAX_UINT || height == 0 ||
-        height > PNG_MAX_UINT)
-      png_error(png_ptr, "Invalid image size in IHDR");
-
-   /* check other values */
-   if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
-      bit_depth != 8 && bit_depth != 16)
-      png_error(png_ptr, "Invalid bit depth in IHDR");
-
-   if (color_type < 0 || color_type == 1 ||
-      color_type == 5 || color_type > 6)
-      png_error(png_ptr, "Invalid color type in IHDR");
-
-   if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
-       ((color_type == PNG_COLOR_TYPE_RGB ||
-         color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
-         color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
-      png_error(png_ptr, "Invalid color type/bit depth combination in IHDR");
-
-   if (interlace_type >= PNG_INTERLACE_LAST)
-      png_error(png_ptr, "Unknown interlace method in IHDR");
-
-   if (compression_type != PNG_COMPRESSION_TYPE_BASE)
-      png_error(png_ptr, "Unknown compression method in IHDR");
-
-#if defined(PNG_MNG_FEATURES_SUPPORTED)
-   /* Accept filter_method 64 (intrapixel differencing) only if
-    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
-    * 2. Libpng did not read a PNG signature (this filter_method is only
-    *    used in PNG datastreams that are embedded in MNG datastreams) and
-    * 3. The application called png_permit_mng_features with a mask that
-    *    included PNG_FLAG_MNG_FILTER_64 and
-    * 4. The filter_method is 64 and
-    * 5. The color_type is RGB or RGBA
-    */
-   if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
-      png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n");
-   if(filter_type != PNG_FILTER_TYPE_BASE)
-   {
-     if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
-        (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
-        ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
-        (color_type == PNG_COLOR_TYPE_RGB || 
-         color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
-        png_error(png_ptr, "Unknown filter method in IHDR");
-     if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
-        png_warning(png_ptr, "Invalid filter method in IHDR");
-   }
-#else
-   if(filter_type != PNG_FILTER_TYPE_BASE)
-      png_error(png_ptr, "Unknown filter method in IHDR");
-#endif
 
    /* set internal variables */
    png_ptr->width = width;
@@ -449,6 +396,13 @@
 
    png_ptr->mode |= PNG_HAVE_PLTE;
 
+   if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
+   {
+      png_warning(png_ptr,
+        "Ignoring PLTE chunk in grayscale PNG");
+      png_crc_finish(png_ptr, length);
+      return;
+   }
 #if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
    if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
    {
@@ -626,7 +580,11 @@
    igamma = (png_fixed_point)png_get_uint_32(buf);
    /* check for zero gamma */
    if (igamma == 0)
-      return;
+      {
+         png_warning(png_ptr,
+           "Ignoring gAMA chunk with gamma=0");
+         return;
+      }
 
 #if defined(PNG_READ_sRGB_SUPPORTED)
    if (info_ptr->valid & PNG_INFO_sRGB)
@@ -1127,7 +1085,7 @@
 
    chunkdata = (png_bytep)png_malloc(png_ptr, length + 1);
    slength = (png_size_t)length;
-   png_crc_read(png_ptr, chunkdata, slength);
+   png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
 
    if (png_crc_finish(png_ptr, skip))
    {
@@ -1157,7 +1115,8 @@
    if (data_length % entry_size)
    {
       png_free(png_ptr, chunkdata);
-      png_error(png_ptr, "sPLT chunk has bad length");
+      png_warning(png_ptr, "sPLT chunk has bad length");
+      return;
    }
 
    new_palette.nentries = data_length / entry_size;
@@ -1714,8 +1673,8 @@
    }
 #else
 #ifdef PNG_FIXED_POINT_SUPPORTED
-   swidth = (png_charp)png_malloc(png_ptr, strlen(ep) + 1);
-   png_memcpy(swidth, ep, (png_size_t)strlen(ep));
+   swidth = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1);
+   png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
 #endif
 #endif
 
@@ -1732,8 +1691,8 @@
    }
 #else
 #ifdef PNG_FIXED_POINT_SUPPORTED
-   sheight = (png_charp)png_malloc(png_ptr, strlen(ep) + 1);
-   png_memcpy(sheight, ep, (png_size_t)strlen(ep));
+   sheight = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1);
+   png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
 #endif
 #endif
 
@@ -1906,7 +1865,7 @@
 #endif
 
    chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
-   slength = (png_size_t)length;
+     slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
    if (png_crc_finish(png_ptr, 0))
    {
@@ -2080,7 +2039,7 @@
       if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
            HANDLE_CHUNK_ALWAYS
 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
-           && png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
+           && png_ptr->read_user_chunk_fn == NULL
 #endif
         )
 #endif
@@ -2100,12 +2059,12 @@
            length = (png_uint_32)65535L;
        }
 #endif
-       strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
+       png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
        chunk.data = (png_bytep)png_malloc(png_ptr, length);
-       png_crc_read(png_ptr, chunk.data, length);
-       chunk.size = length;
+       chunk.size = (png_size_t)length;
+       png_crc_read(png_ptr, (png_bytep)chunk.data, length);
 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
-       if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
+       if(png_ptr->read_user_chunk_fn != NULL)
        {
           /* callback to user unknown chunk handler */
           if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
@@ -2368,6 +2327,10 @@
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
 #ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE   /* else in pngvcrd.c, pnggccrd.c */
+/* OLD pre-1.0.9 interface:
+void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
+   png_uint_32 transformations)
+ */
 void /* PRIVATE */
 png_do_read_interlace(png_structp png_ptr)
 {
@@ -3003,6 +2966,7 @@
       png_error(png_ptr, "This image requires a row greater than 64KB");
 #endif
    png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes);
+   png_ptr->row_buf_size = row_bytes;
 
 #ifdef PNG_MAX_MALLOC_64K
    if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
diff --git a/pngset.c b/pngset.c
index f851fac..096d44c 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -109,9 +109,10 @@
    info_ptr->int_gamma = (int)(file_gamma*100000.+.5);
 #endif
    info_ptr->valid |= PNG_INFO_gAMA;
+   if(file_gamma == 0.0)
+      png_warning(png_ptr, "Setting gamma=0");
 }
 #endif
-#endif
 void PNGAPI
 png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
    int_gamma)
@@ -127,7 +128,10 @@
    info_ptr->int_gamma = int_gamma;
 #endif
    info_ptr->valid |= PNG_INFO_gAMA;
+   if(int_gamma == 0)
+      png_warning(png_ptr, "Setting gamma=0");
 }
+#endif
 
 #if defined(PNG_hIST_SUPPORTED)
 void PNGAPI
@@ -139,8 +143,11 @@
    if (png_ptr == NULL || info_ptr == NULL)
       return;
    if (info_ptr->num_palette == 0)
+   {
        png_warning(png_ptr,
-		   "Palette size 0, hIST allocation skipped.");
+          "Palette size 0, hIST allocation skipped.");
+       return;
+   }
 
 #ifdef PNG_FREE_ME_SUPPORTED
    png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
@@ -172,6 +179,61 @@
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
+   /* check for width and height valid values */
+   if (width == 0 || height == 0)
+      png_error(png_ptr, "Image width or height is zero in IHDR");
+   if (width > PNG_MAX_UINT || height > PNG_MAX_UINT)
+      png_error(png_ptr, "Invalid image size in IHDR");
+
+   /* check other values */
+   if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
+      bit_depth != 8 && bit_depth != 16)
+      png_error(png_ptr, "Invalid bit depth in IHDR");
+
+   if (color_type < 0 || color_type == 1 ||
+      color_type == 5 || color_type > 6)
+      png_error(png_ptr, "Invalid color type in IHDR");
+
+   if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
+       ((color_type == PNG_COLOR_TYPE_RGB ||
+         color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
+         color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
+      png_error(png_ptr, "Invalid color type/bit depth combination in IHDR");
+
+   if (interlace_type >= PNG_INTERLACE_LAST)
+      png_error(png_ptr, "Unknown interlace method in IHDR");
+
+   if (compression_type != PNG_COMPRESSION_TYPE_BASE)
+      png_error(png_ptr, "Unknown compression method in IHDR");
+
+#if defined(PNG_MNG_FEATURES_SUPPORTED)
+   /* Accept filter_method 64 (intrapixel differencing) only if
+    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
+    * 2. Libpng did not read a PNG signature (this filter_method is only
+    *    used in PNG datastreams that are embedded in MNG datastreams) and
+    * 3. The application called png_permit_mng_features with a mask that
+    *    included PNG_FLAG_MNG_FILTER_64 and
+    * 4. The filter_method is 64 and
+    * 5. The color_type is RGB or RGBA
+    */
+   if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
+      png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n");
+   if(filter_type != PNG_FILTER_TYPE_BASE)
+   {
+     if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
+        (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
+        ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
+        (color_type == PNG_COLOR_TYPE_RGB || 
+         color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
+        png_error(png_ptr, "Unknown filter method in IHDR");
+     if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
+        png_warning(png_ptr, "Invalid filter method in IHDR");
+   }
+#else
+   if(filter_type != PNG_FILTER_TYPE_BASE)
+      png_error(png_ptr, "Unknown filter method in IHDR");
+#endif
+
    info_ptr->width = width;
    info_ptr->height = height;
    info_ptr->bit_depth = (png_byte)bit_depth;
@@ -248,6 +310,7 @@
 
    info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr,
       (png_uint_32)((nparams + 1) * sizeof(png_charp)));
+
    info_ptr->pcal_params[nparams] = NULL;
 
    for (i = 0; i < nparams; i++)
@@ -302,7 +365,7 @@
 
    length = png_strlen(sheight) + 1;
    png_debug1(3, "allocating unit for info (%d bytes)\n", length);
-   info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length);
+   info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length);
    png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
 
    info_ptr->valid |= PNG_INFO_sCAL;
@@ -349,7 +412,7 @@
 #endif
    png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)num_palette,
       sizeof (png_color));
-   memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color));
+   png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color));
    info_ptr->palette = png_ptr->palette;
    info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
 
@@ -472,9 +535,9 @@
    if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
       return;
 
-   new_iccp_name = png_malloc(png_ptr, png_strlen(name)+1);
-   strcpy(new_iccp_name, name);
-   new_iccp_profile = png_malloc(png_ptr, proflen);
+   new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1);
+   png_strcpy(new_iccp_name, name);
+   new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen);
    png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
 
    png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
@@ -543,7 +606,7 @@
       png_size_t lang_len,lang_key_len;
       png_textp textp = &(info_ptr->text[info_ptr->num_text]);
 
-      if (text_ptr[i].key == (png_charp)NULL)
+      if (text_ptr[i].key == NULL)
           continue;
 
       key_len = png_strlen(text_ptr[i].key);
@@ -557,11 +620,11 @@
 #ifdef PNG_iTXt_SUPPORTED
       {
         /* set iTXt data */
-        if (text_ptr[i].key != (png_charp)NULL)
+        if (text_ptr[i].key != NULL)
           lang_len = png_strlen(text_ptr[i].lang);
         else
           lang_len = 0;
-        if (text_ptr[i].lang_key != (png_charp)NULL)
+        if (text_ptr[i].lang_key != NULL)
           lang_key_len = png_strlen(text_ptr[i].lang_key);
         else
           lang_key_len = 0;
@@ -573,7 +636,7 @@
       }
 #endif
 
-      if (text_ptr[i].text == (png_charp)NULL || text_ptr[i].text[0] == '\0')
+      if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
       {
          text_length = 0;
 #ifdef PNG_iTXt_SUPPORTED
@@ -676,8 +739,9 @@
 #ifdef PNG_FREE_ME_SUPPORTED
        png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
 #endif
-       png_ptr->trans = info_ptr->trans = png_malloc(png_ptr, num_trans);
-       memcpy(info_ptr->trans, trans, num_trans);
+       png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
+           num_trans);
+       png_memcpy(info_ptr->trans, trans, num_trans);
 #ifdef PNG_FREE_ME_SUPPORTED
        info_ptr->free_me |= PNG_FREE_TRNS;
 #else
@@ -719,12 +783,12 @@
         png_sPLT_tp from = entries + i;
 
         to->name = (png_charp)png_malloc(png_ptr,
-                                        png_strlen(from->name) + 1);
+            png_strlen(from->name) + 1);
         png_strcpy(to->name, from->name);
         to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
-                                 from->nentries * sizeof(png_sPLT_t));
+            from->nentries * sizeof(png_sPLT_t));
         png_memcpy(to->entries, from->entries,
-               from->nentries * sizeof(png_sPLT_t));
+            from->nentries * sizeof(png_sPLT_t));
         to->nentries = from->nentries;
         to->depth = from->depth;
     }
@@ -738,7 +802,7 @@
 }
 #endif /* PNG_sPLT_SUPPORTED */
 
-#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
 void PNGAPI
 png_set_unknown_chunks(png_structp png_ptr,
    png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
@@ -840,8 +904,8 @@
     if (chunk_list == NULL)
       return;
     old_num_chunks=png_ptr->num_chunk_list;
-    new_list=png_malloc(png_ptr,5*(num_chunks+old_num_chunks));
-    if(png_ptr->chunk_list != (png_bytep)NULL)
+    new_list=(png_bytep)png_malloc(png_ptr,5*(num_chunks+old_num_chunks));
+    if(png_ptr->chunk_list != NULL)
     {
        png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
        png_free(png_ptr, png_ptr->chunk_list);
@@ -883,7 +947,6 @@
    info_ptr->row_pointers = row_pointers;
    if(row_pointers)
       info_ptr->valid |= PNG_INFO_IDAT;
-
 }
 #endif
 
@@ -894,8 +957,6 @@
        png_free(png_ptr, png_ptr->zbuf);
     png_ptr->zbuf_size = (png_size_t)size;
     png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
-    if(!png_ptr->zbuf)
-       png_error(png_ptr,"Unable to malloc zbuf");
     png_ptr->zstream.next_out = png_ptr->zbuf;
     png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
 }
diff --git a/pngtest.c b/pngtest.c
index 09590fe..0ddd544 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -51,16 +51,20 @@
 #endif
 
 #if defined(PNG_NO_STDIO)
-#if defined(_WIN32_WCE)
-typedef HANDLE                png_FILE_p;
-#else
-typedef FILE                * png_FILE_p;
-#endif
+#  if defined(_WIN32_WCE)
+     typedef HANDLE                png_FILE_p;
+#  else
+     typedef FILE                * png_FILE_p;
+#  endif
 #endif
 
 /* Makes pngtest verbose so we can find problems (needs to be before png.h) */
 #ifndef PNG_DEBUG
-#define PNG_DEBUG 0
+#  define PNG_DEBUG 0
+#endif
+
+#if !PNG_DEBUG
+#  define SINGLE_ROWBUF_ALLOC	/* makes buffer overruns easier to nail */
 #endif
 
 /* Turn on CPU timing
@@ -279,7 +283,7 @@
 
    if (check != length)
    {
-      png_error(png_ptr, "Read Error");
+      png_error(png_ptr, "Read Error!");
    }
 }
 #else
@@ -484,14 +488,15 @@
    /* This calls the library allocator twice, once to get the requested
       buffer and once to get a new free list entry. */
    {
-      memory_infop pinfo = png_malloc_default(png_ptr, sizeof *pinfo);
+      memory_infop pinfo = (memory_infop)png_malloc_default(png_ptr,
+         sizeof *pinfo);
       pinfo->size = size;
       current_allocation += size;
       total_allocation += size;
       num_allocations ++;
       if (current_allocation > maximum_allocation)
          maximum_allocation = current_allocation;
-      pinfo->pointer = png_malloc_default(png_ptr, size);
+      pinfo->pointer = (png_voidp)png_malloc_default(png_ptr, size);
       pinfo->next = pinformation;
       pinformation = pinfo;
       /* Make sure the caller isn't assuming zeroed memory. */
@@ -533,7 +538,7 @@
                fprintf(STDERR, "Duplicate free of memory\n");
             /* We must free the list element too, but first kill
                the memory that is to be freed. */
-            memset(ptr, 0x55, pinfo->size);
+            png_memset(ptr, 0x55, pinfo->size);
             png_free_default(png_ptr, pinfo);
             pinfo=NULL;
             break;
@@ -564,8 +569,17 @@
 {
    static png_FILE_p fpin;
    static png_FILE_p fpout;  /* "static" prevents setjmp corruption */
-   png_structp read_ptr, write_ptr;
-   png_infop read_info_ptr, write_info_ptr, end_info_ptr, write_end_info_ptr;
+   png_structp read_ptr;
+   png_infop read_info_ptr, end_info_ptr;
+#ifdef PNG_WRITE_SUPPORTED
+   png_structp write_ptr;
+   png_infop write_info_ptr;
+   png_infop write_end_info_ptr;
+#else
+   png_structp write_ptr = NULL;
+   png_infop write_info_ptr = NULL;
+   png_infop write_end_info_ptr = NULL;
+#endif
    png_bytep row_buf;
    png_uint_32 y;
    png_uint_32 width, height;
@@ -620,6 +634,7 @@
    png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
        pngtest_warning);
 #endif
+#ifdef PNG_WRITE_SUPPORTED
 #ifdef PNG_USER_MEM_SUPPORTED
    write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
       (png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL,
@@ -632,12 +647,13 @@
    png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error,
        pngtest_warning);
 #endif
+#endif
    png_debug(0, "Allocating read_info, write_info and end_info structures\n");
    read_info_ptr = png_create_info_struct(read_ptr);
-   write_info_ptr = png_create_info_struct(write_ptr);
    end_info_ptr = png_create_info_struct(read_ptr);
+#ifdef PNG_WRITE_SUPPORTED
+   write_info_ptr = png_create_info_struct(write_ptr);
    write_end_info_ptr = png_create_info_struct(write_ptr);
-#ifdef PNG_USER_MEM_SUPPORTED
 #endif
 
 #ifdef PNG_SETJMP_SUPPORTED
@@ -650,8 +666,10 @@
    {
       fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
       png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
+#ifdef PNG_WRITE_SUPPORTED
       png_destroy_info_struct(write_ptr, &write_end_info_ptr);
       png_destroy_write_struct(&write_ptr, &write_info_ptr);
+#endif
       FCLOSE(fpin);
       FCLOSE(fpout);
       return (1);
@@ -660,6 +678,7 @@
    png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf));
 #endif
 
+#ifdef PNG_WRITE_SUPPORTED
    png_debug(0, "Setting jmpbuf for write struct\n");
 #ifdef USE_FAR_KEYWORD
    if (setjmp(jmpbuf))
@@ -670,7 +689,9 @@
       fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
       png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
       png_destroy_info_struct(write_ptr, &write_end_info_ptr);
+#ifdef PNG_WRITE_SUPPORTED
       png_destroy_write_struct(&write_ptr, &write_info_ptr);
+#endif
       FCLOSE(fpin);
       FCLOSE(fpout);
       return (1);
@@ -679,28 +700,37 @@
    png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf));
 #endif
 #endif
+#endif
 
    png_debug(0, "Initializing input and output streams\n");
 #if !defined(PNG_NO_STDIO)
    png_init_io(read_ptr, fpin);
+#  ifdef PNG_WRITE_SUPPORTED
    png_init_io(write_ptr, fpout);
+#  endif
 #else
    png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data);
+#ifdef PNG_WRITE_SUPPORTED
    png_set_write_fn(write_ptr, (png_voidp)fpout,  pngtest_write_data,
 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
       pngtest_flush);
 #else
+#endif
       NULL);
 #endif
 #endif
    if(status_dots_requested == 1)
    {
+#ifdef PNG_WRITE_SUPPORTED
       png_set_write_status_fn(write_ptr, write_row_callback);
+#endif
       png_set_read_status_fn(read_ptr, read_row_callback);
    }
    else
    {
+#ifdef PNG_WRITE_SUPPORTED
       png_set_write_status_fn(write_ptr, NULL);
+#endif
       png_set_read_status_fn(read_ptr, NULL);
    }
 
@@ -984,32 +1014,29 @@
    }
 #endif
 
+#ifdef PNG_WRITE_SUPPORTED
    png_debug(0, "\nWriting info struct\n");
 
 /* If we wanted, we could write info in two steps:
    png_write_info_before_PLTE(write_ptr, write_info_ptr);
  */
    png_write_info(write_ptr, write_info_ptr);
+#endif
 
-   png_debug(0, "\nAllocating row buffer \n");
+#ifdef SINGLE_ROWBUF_ALLOC
+   png_debug(0, "\nAllocating row buffer...");
    row_buf = (png_bytep)png_malloc(read_ptr,
       png_get_rowbytes(read_ptr, read_info_ptr));
-   if (row_buf == NULL)
-   {
-      fprintf(STDERR, "No memory to allocate row buffer\n");
-      png_destroy_read_struct(&read_ptr, &read_info_ptr, (png_infopp)NULL);
-      png_destroy_info_struct(write_ptr, &write_end_info_ptr);
-      png_destroy_write_struct(&write_ptr, &write_info_ptr);
-      FCLOSE(fpin);
-      FCLOSE(fpout);
-      return (1);
-   }
+   png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf);
+#endif /* SINGLE_ROWBUF_ALLOC */
    png_debug(0, "Writing row data\n");
 
 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
   defined(PNG_WRITE_INTERLACING_SUPPORTED)
    num_pass = png_set_interlace_handling(read_ptr);
+#  ifdef PNG_WRITE_SUPPORTED
    png_set_interlace_handling(write_ptr);
+#  endif
 #else
    num_pass=1;
 #endif
@@ -1024,7 +1051,16 @@
       png_debug1(0, "Writing row data for pass %d\n",pass);
       for (y = 0; y < height; y++)
       {
+#ifndef SINGLE_ROWBUF_ALLOC
+         png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y);
+         row_buf = (png_bytep)png_malloc(read_ptr,
+            png_get_rowbytes(read_ptr, read_info_ptr));
+         png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf,
+            png_get_rowbytes(read_ptr, read_info_ptr));
+#endif /* !SINGLE_ROWBUF_ALLOC */
          png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1);
+
+#ifdef PNG_WRITE_SUPPORTED
 #ifdef PNGTEST_TIMING
          t_stop = (float)clock();
          t_decode += (t_stop - t_start);
@@ -1036,6 +1072,12 @@
          t_encode += (t_stop - t_start);
          t_start = t_stop;
 #endif
+#endif /* PNG_WRITE_SUPPORTED */
+
+#ifndef SINGLE_ROWBUF_ALLOC
+         png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y);
+         png_free(read_ptr, row_buf);
+#endif /* !SINGLE_ROWBUF_ALLOC */
       }
    }
 
@@ -1098,7 +1140,9 @@
       }
    }
 #endif
+#ifdef PNG_WRITE_SUPPORTED
    png_write_end(write_ptr, write_end_info_ptr);
+#endif
 
 #ifdef PNG_EASY_ACCESS_SUPPORTED
    if(verbose)
@@ -1112,11 +1156,20 @@
 #endif
 
    png_debug(0, "Destroying data structs\n");
+#ifdef SINGLE_ROWBUF_ALLOC
+   png_debug(1, "destroying row_buf for read_ptr\n");
    png_free(read_ptr, row_buf);
    row_buf=NULL;
+#endif /* SINGLE_ROWBUF_ALLOC */
+   png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n");
    png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
+#ifdef PNG_WRITE_SUPPORTED
+   png_debug(1, "destroying write_end_info_ptr\n");
    png_destroy_info_struct(write_ptr, &write_end_info_ptr);
+   png_debug(1, "destroying write_ptr, write_info_ptr\n");
    png_destroy_write_struct(&write_ptr, &write_info_ptr);
+#endif
+   png_debug(0, "Destruction complete.\n");
 
    FCLOSE(fpin);
    FCLOSE(fpout);
@@ -1458,4 +1511,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_0beta1 your_png_h_is_not_version_1_2_0beta1;
+typedef version_1_2_0beta2 your_png_h_is_not_version_1_2_0beta2;
diff --git a/pngtrans.c b/pngtrans.c
index 5bc4ad5..12f6f23 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,7 +1,7 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -392,11 +392,12 @@
                sp += 8; dp += 6;
                for (i = 1; i < row_width; i++)
                {
-                  /* This could be (although memcpy is probably slower):
+                  /* This could be (although png_memcpy is probably slower):
                   png_memcpy(dp, sp, 6);
                   sp += 8;
                   dp += 6;
                   */
+
                   *dp++ = *sp++;
                   *dp++ = *sp++;
                   *dp++ = *sp++;
@@ -411,11 +412,12 @@
                /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
                for (i = 0; i < row_width; i++)
                {
-                  /* This could be (although memcpy is probably slower):
+                  /* This could be (although png_memcpy is probably slower):
                   png_memcpy(dp, sp, 6);
                   sp += 8;
                   dp += 6;
                   */
+
                   sp+=2;
                   *dp++ = *sp++;
                   *dp++ = *sp++;
diff --git a/pngvcrd.c b/pngvcrd.c
index 04c2025..fe9fe9f 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngwio.c b/pngwio.c
index febf217..9ada920 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -17,6 +17,7 @@
 
 #define PNG_INTERNAL
 #include "png.h"
+#ifdef PNG_WRITE_SUPPORTED
 
 /* Write the data to whatever output you are using.  The default routine
    writes to a file pointer.  Note that this routine sometimes gets called
@@ -224,3 +225,4 @@
 }
 #   endif
 #   endif
+#endif /* PNG_WRITE_SUPPORTED */
diff --git a/pngwrite.c b/pngwrite.c
index 6067367..b1d6ec0 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngwtran.c b/pngwtran.c
index 0671ec5..64ec765 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,7 +1,7 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -10,6 +10,7 @@
 
 #define PNG_INTERNAL
 #include "png.h"
+#ifdef PNG_WRITE_SUPPORTED
 
 /* Transform the data according to the user's wishes.  The order of
  * transformations is significant.
@@ -559,3 +560,4 @@
    }
 }
 #endif /* PNG_MNG_FEATURES_SUPPORTED */
+#endif /* PNG_WRITE_SUPPORTED */
diff --git a/pngwutil.c b/pngwutil.c
index 4bbb7ad..da31079 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -10,6 +10,7 @@
 
 #define PNG_INTERNAL
 #include "png.h"
+#ifdef PNG_WRITE_SUPPORTED
 
 /* Place a 32-bit number into a buffer in PNG byte order.  We work
  * with unsigned numbers for convenience, although one supported
@@ -234,8 +235,8 @@
                old_ptr = comp->output_ptr;
                comp->output_ptr = (png_charpp)png_malloc(png_ptr,
                   (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
-               png_memcpy(comp->output_ptr, old_ptr,
-           old_max * sizeof (png_charp));
+               png_memcpy(comp->output_ptr, old_ptr, old_max
+                  * sizeof (png_charp));
                png_free(png_ptr, old_ptr);
             }
             else
@@ -284,7 +285,7 @@
                   comp->output_ptr = (png_charpp)png_malloc(png_ptr,
                      (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
                   png_memcpy(comp->output_ptr, old_ptr,
-              old_max * sizeof (png_charp));
+                     old_max * sizeof (png_charp));
                   png_free(png_ptr, old_ptr);
                }
                else
@@ -434,7 +435,7 @@
 #if defined(PNG_MNG_FEATURES_SUPPORTED)
       !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
       ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
-      (color_type == PNG_COLOR_TYPE_RGB || 
+      (color_type == PNG_COLOR_TYPE_RGB ||
        color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
       (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
 #endif
@@ -538,16 +539,23 @@
         !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
 #endif
         num_pal == 0) || num_pal > 256)
+   {
+     if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
      {
-       if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-         {
-           png_error(png_ptr, "Invalid number of colors in palette");
-         }
-       else
-         {
-           png_warning(png_ptr, "Invalid number of colors in palette");
-           return;
-         }
+        png_error(png_ptr, "Invalid number of colors in palette");
+     }
+     else
+     {
+        png_warning(png_ptr, "Invalid number of colors in palette");
+        return;
+     }
+   }
+
+   if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
+   {
+      png_warning(png_ptr,
+        "Ignoring request to write a PLTE chunk in grayscale PNG");
+      return;
    }
 
    png_ptr->num_palette = (png_uint_16)num_pal;
@@ -728,7 +736,7 @@
    }
 
    /* make sure we include the NULL after the name */
-   png_write_chunk_start(png_ptr, (png_bytep) png_sPLT,
+   png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,
           (png_uint_32)(name_len + 2 + palette_size));
    png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
    png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
@@ -1486,8 +1494,8 @@
    png_debug1(3, "sCAL total length = %d\n", total_len);
    png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
    png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
-   png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1);
-   png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf));
+   png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);
+   png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));
 
    png_write_chunk_end(png_ptr);
 }
@@ -1505,15 +1513,15 @@
 
    png_debug(1, "in png_write_sCAL_s\n");
 
-   strcpy(wbuf,(const char *)width);
-   strcpy(hbuf,(const char *)height);
+   png_strcpy(wbuf,(const char *)width);
+   png_strcpy(hbuf,(const char *)height);
    total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
 
    png_debug1(3, "sCAL total length = %d\n", total_len);
    png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
    png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
-   png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1);
-   png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf));
+   png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);
+   png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));
 
    png_write_chunk_end(png_ptr);
 }
@@ -2631,3 +2639,4 @@
    }
 #endif
 }
+#endif /* PNG_WRITE_SUPPORTED */
diff --git a/projects/msvc/README.txt b/projects/msvc/README.txt
index 9df523d..c743851 100644
--- a/projects/msvc/README.txt
+++ b/projects/msvc/README.txt
@@ -1,5 +1,5 @@
 Microsoft Developer Studio Build File, Format Version 6.00 for
-libpng 1.2.0beta1 (May 6, 2001) and zlib
+libpng 1.2.0beta2 (May 7, 2001) and zlib
 
 Copyright (C) 2000 Simon-Pierre Cadieux
 For conditions of distribution and use, see copyright notice in png.h
diff --git a/projects/msvc/png32ms.def b/projects/msvc/png32ms.def
index 83e2231..2184d9c 100644
--- a/projects/msvc/png32ms.def
+++ b/projects/msvc/png32ms.def
@@ -6,7 +6,7 @@
 DESCRIPTION "PNG image compression library for Windows"
 
 EXPORTS
-;Version 1.2.0beta1
+;Version 1.2.0beta2
   png_build_grayscale_palette  @1
   png_check_sig        @2
   png_chunk_error      @3
diff --git a/projects/wince/READMEE.WCE b/projects/wince/READMEE.WCE
index 9d15273..e048b80 100644
--- a/projects/wince/READMEE.WCE
+++ b/projects/wince/READMEE.WCE
@@ -8,9 +8,9 @@
 
 Introduction
 ============
-This is libpng 1.2.0beta1 ported to WindowsCE 2.0 and 2.11.
-libpng 1.2.0beta1 is a PNG reference library.
-See README, a document of original libpng 1.2.0beta1.
+This is libpng 1.2.0beta2 ported to WindowsCE 2.0 and 2.11.
+libpng 1.2.0beta2 is a PNG reference library.
+See README, a document of original libpng 1.2.0beta2.
 
 zlib for WindowsCE
 ==================
@@ -23,7 +23,7 @@
 warranty.  In no event will the authors be held liable for any damages
 arising from the use of this software.
 
-See README and LICENSE, documents of original libpng 1.2.0beta1, for conditions
+See README and LICENSE, documents of original libpng 1.2.0beta2, for conditions
 of use and distribution.
 
 Files
diff --git a/projects/wince/READMEJ.WCE b/projects/wince/READMEJ.WCE
index bda7cb1..acb4868 100644
--- a/projects/wince/READMEJ.WCE
+++ b/projects/wince/READMEJ.WCE
@@ -24,7 +24,7 @@
 ‚É‚È‚Á‚½‚¢‚©‚È‚é”íŠQ‚ɂ‚¢‚Ä‚àAìŽÒA”z•zŽÒA‚»‚Ì‘¼—˜—pŽÒˆÈŠO‚̐l•¨A
 ’c‘̂ɐӔC‚ð‚Æ‚é‹`–±‚Í‚È‚¢‚à‚Ì‚Æ‚µ‚Ü‚·B
 
-‚»‚Ì‘¼A‚±‚̃\ƒtƒgƒEƒFƒA‚Ì—˜—pðŒ‚ɂ‚¢‚ẮAŒ´”Å‚Å‚ ‚é libpng 1.2.0beta1‚É
+‚»‚Ì‘¼A‚±‚̃\ƒtƒgƒEƒFƒA‚Ì—˜—pðŒ‚ɂ‚¢‚ẮAŒ´”Å‚Å‚ ‚é libpng 1.2.0beta2‚É
 €‹’‚·‚é‚à‚Ì‚Æ‚µ‚Ü‚·BÚ‚µ‚­‚́A•t‘®‚Ì README,LICENSE ‚ð‚¨“Ç‚Ý‚­‚¾‚³‚¢B
 
 Žû˜^“à—e
diff --git a/projects/wince/png32ce.def b/projects/wince/png32ce.def
index ddb870f..b2af103 100644
--- a/projects/wince/png32ce.def
+++ b/projects/wince/png32ce.def
@@ -5,7 +5,7 @@
 LIBRARY lpngce
 
 EXPORTS
-;Version 1.2.0beta1
+;Version 1.2.0beta2
   png_build_grayscale_palette  @1
   png_check_sig        @2
   png_chunk_error      @3
diff --git a/scripts/makefile.aix b/scripts/makefile.aix
index 38169d3..354b4f4 100644
--- a/scripts/makefile.aix
+++ b/scripts/makefile.aix
@@ -18,7 +18,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 prefix=/usr/local
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index 3ccda73..c8c6911 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -13,7 +13,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 ALIGN=
diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin
index de9d218..346c245 100644
--- a/scripts/makefile.cygwin
+++ b/scripts/makefile.cygwin
@@ -39,8 +39,8 @@
 # have to change it.
 PNGMAJ = 2
 #PNGDLL = $2# msvc
-PNGDLL = 2# cygwin 1.2.0beta1
-PNGMIN = 1.2.0beta1
+PNGDLL = 2# cygwin 1.2.0beta2
+PNGMIN = 1.2.0beta2
 PNGMIN_BASE = 1.2.0
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 000d7f6..5a8b3d6 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -17,7 +17,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=cc
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index 4a5a986..24cbb8b 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -51,7 +51,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc
index 7c6930a..da0ab06 100644
--- a/scripts/makefile.hpgcc
+++ b/scripts/makefile.hpgcc
@@ -34,7 +34,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index 692ce1b..ef0eb4a 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -19,7 +19,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # where make install puts libpng.a and png.h
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 0eb6946..c22696e 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -34,7 +34,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd
index 056d662..e6cd673 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -11,7 +11,7 @@
 
 LIB=png
 SHLIB_MAJOR= 2
-SHLIB_MINOR= 1.2.0beta1
+SHLIB_MINOR= 1.2.0beta2
 SRCS=	pnggccrd.c 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.sco b/scripts/makefile.sco
index 15b4ca2..ca96355 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -25,7 +25,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index efbfe67..4aa7e99 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -19,8 +19,8 @@
 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
 LDSHARED=gcc -shared
 
-VER=1.2.0beta1
-LIBS=libpng.so.1.2.0beta1
+VER=1.2.0beta2
+LIBS=libpng.so.1.2.0beta2
 SHAREDLIB=libpng.so
 libdir=$(prefix)/lib32
 
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index 9ce67c1..946b9f7 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -25,7 +25,7 @@
 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
 LDSHARED=cc -shared
 
-VER=1.2.0beta1
+VER=1.2.0beta2
 SONUM=2
 SHAREDLIB=libpng.so
 libdir=$(prefix)
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index 2aec98a..fa03087 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -31,7 +31,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.2.0beta1
+PNGMIN = 1.2.0beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index 88be81b..22d0ba1 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -7,7 +7,7 @@
 interface
 
 const
-  PNG_LIBPNG_VER_STRING = '1.2.0beta1';
+  PNG_LIBPNG_VER_STRING = '1.2.0beta2';
   PNG_LIBPNG_VER        =  10200;
 
 type
diff --git a/scripts/pngos2.def b/scripts/pngos2.def
index 8392588..ca8ce66 100644
--- a/scripts/pngos2.def
+++ b/scripts/pngos2.def
@@ -2,7 +2,7 @@
 ; PNG.LIB module definition file for OS/2
 ;----------------------------------------
 
-; Version 1.2.0beta1
+; Version 1.2.0beta2
 
 LIBRARY		PNG
 DESCRIPTION	"PNG image compression library for OS/2"