Imported from libpng-1.2.4beta1.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index 579c7e4..85cfb53 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,37 +1,17 @@
 
-Libpng 1.2.3 - May 21, 2002
+Libpng 1.2.4beta1 - May 25, 2002
 
-This is a public release of libpng, intended for use in production codes.
+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.
 
-Changes since the last public release (1.2.2):
+Changes since the last public release (1.2.3):
 
-  Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc
-  Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install
-  Added install: target to makefile.32sunu and makefile.64sunu
-  Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng
-    subdirectory to libpngNN subdirectory without the full pathname.
-  Moved generation of libpng.pc from "install" to "all" in 15 makefiles.
-  Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos).
-  Added $(DESTDIR) feature to 24 makefiles (Tim Mooney)
-  Fixed bug with $prefix, should be $(prefix) in makefile.hpux.
-  Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin
-  Added a link from libpngNN.pc to libpng.pc in 15 makefiles.
-  Added links from include/libpngNN/*.h to include/*.h in 24 makefiles.
-  Revised makefile.darwin to make relative links without full pathname.
-  Added setjmp() at the end of png_create_*_struct_2() in case user forgets
-    to put one in their application.
-  Fixed bug in reporting number of channels in pngget.c, introduced in
-    version 1.2.2
-  Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles.
-  Remove old libpng.pc and libpngNN.pc before installing new ones.
-  Revised 15 makefiles to build libpng-config and libpngNN-config from
-    libpng-config-*.in.
-  Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp
-  Changed "error" and "message" in prototypes to "error_message" and
-    "warning_message" to avoid namespace conflict.
-  Restored png_zalloc and png_zfree to nonexported form as in libpng-1.2.1.
-  Removed description of png_set_mem_fn() from documentation.
-  Revised projects/msvc/README.txt
+version 1.2.4beta1 [May 25, 2002]
+  Added libpng.pc and libpng-config to "all:" target in 16 makefiles.
+  Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH)
+  Added missing "\" before closing double quote in makefile.gcmmx.
+  Plugged various memory leaks; added png_malloc_warn() and png_set_text_2()
+    functions.
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index 0a70315..c0f3c17 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1118,13 +1118,19 @@
   Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp.
   Removed leftover libpng-config "sed" script from four makefiles.
   Revised libpng-config creating script in 16 makefiles.
-version 1.2.3 [May 21, 2002]
+version 1.2.3 [May 22, 2002]
   Revised libpng-config target in makefile.cygwin.
   Removed description of png_set_mem_fn() from documentation.
   Revised makefile.freebsd.
   Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR).
   Revised projects/msvc/README.txt
   Changed -lpng to -lpngNN in LDFLAGS in several makefiles.
+version 1.2.4beta1 [May 25, 2002]
+  Added libpng.pc and libpng-config to "all:" target in 16 makefiles.
+  Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH)
+  Added missing "\" before closing double quote in makefile.gcmmx.
+  Plugged various memory leaks; added png_malloc_warn() and png_set_text_2()
+    functions.
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/INSTALL b/INSTALL
index 0afc525..b192880 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.2.3 - May 21, 2002
+Installing libpng version 1.2.4beta1 - May 25, 2002
 
 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.3" or "lpng109" and "zlib-1.1.3"
+might be called "libpng-1.2.4beta1" 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:
@@ -64,8 +64,8 @@
 include
 
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
- makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng12.so.0.1.2.3)
- makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng12.so.0.1.2.3,
+ makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng12.so.0.1.2.4beta1)
+ makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng12.so.0.1.2.4beta1,
                        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
@@ -86,10 +86,10 @@
  makefile.ne0bsd  =>  NetBSD/cc makefile, uses PNGGCCRD, makes libpng0.so
  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.3)
+ makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng12.so.0.1.2.4beta1)
  makefile.sunos    =>  Sun makefile
- makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng12.so.0.1.2.3)
- makefile.so9      =>  Solaris 9 makefile (gcc, creates libpng12.so.0.1.2.3)
+ makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng12.so.0.1.2.4beta1)
+ makefile.so9      =>  Solaris 9 makefile (gcc, creates libpng12.so.0.1.2.4beta1)
  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 a0d1159..ca3f118 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -1,5 +1,5 @@
 
-Known bugs in libpng version 1.2.3
+Known bugs in libpng version 1.2.4beta1
 
 1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when
    reading interlaced PNG files, when assembler code is enabled.
diff --git a/LICENSE b/LICENSE
index c38b8ff..05abcb2 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.3, May 21, 2002, are
+libpng versions 1.0.7, July 1, 2000, through 1.2.4beta1, May 25, 2002, are
 Copyright (c) 2000-2002 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 21, 2002
+May 25, 2002
diff --git a/README b/README
index 026d902..90706a0 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.2.3 - May 21, 2002 (shared library 2.1)
+README for libpng 1.2.4beta1 - May 25, 2002 (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.
@@ -187,9 +187,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 libpng12.so.0.1.2.3)
+                            (gcc, creates libpng12.so.0.1.2.4beta1)
        makefile.gcmmx   =>  Linux/ELF makefile (gcc, creates
-                            libpng12.so.0.1.2.3, uses assembler code
+                            libpng12.so.0.1.2.4beta1, 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
@@ -210,12 +210,12 @@
        makefile.ne0bsd =>  NetBSD/cc makefile, PNGGCCRD, makes libpng0.so
        makefile.openbsd =>  OpenBSD makefile
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
-       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng12.so.0.1.2.3)
+       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng12.so.0.1.2.4beta1)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng12.so.0.1.2.3)
+                            (gcc, creates libpng12.so.0.1.2.4beta1)
        makefile.so9     =>  Solaris 9 makefile
-                            (gcc, creates libpng12.so.0.1.2.3)
+                            (gcc, creates libpng12.so.0.1.2.4beta1)
        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 d5345d3..616a2e8 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      May 21, 2002
+      May 25, 2002
 
       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.3 are Y2K compliant.  It is my belief that earlier
+      upward through 1.2.4beta1 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 f9cc370..453afa7 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 echo "
-  There is no \"configure\" script for Libpng-1.2.3.  Instead, please
+  There is no \"configure\" script for Libpng-1.2.4beta1.  Instead, please
   copy the appropriate makefile for your system from the \"scripts\"
   directory.  Read the INSTALL file for more details.
 "
diff --git a/contrib/pngsuite/README b/contrib/pngsuite/README
deleted file mode 100644
index 714d12c..0000000
--- a/contrib/pngsuite/README
+++ /dev/null
@@ -1,85 +0,0 @@
-
-pngsuite
---------
-(c) Willem van Schaik, 1999
-
-Permission to use, copy, and distribute these images for any purpose and
-without fee is hereby granted.
-
-These 15 images are part of the much larger PngSuite test-set of 
-images, available for developers of PNG supporting software. The 
-complete set, available at http:/www.schaik.com/pngsuite/, contains 
-a variety of images to test interlacing, gamma settings, ancillary
-chunks, etc.
-
-The images in this directory represent the basic PNG color-types:
-grayscale (1-16 bit deep), full color (8 or 16 bit), paletted
-(1-8 bit) and grayscale or color images with alpha channel. You
-can use them to test the proper functioning of PNG software.
-
-    filename      depth type
-    ------------ ------ --------------
-    basn0g01.png  1-bit grayscale
-    basn0g02.png  2-bit grayscale
-    basn0g04.png  4-bit grayscale
-    basn0g08.png  8-bit grayscale
-    basn0g16.png 16-bit grayscale
-    basn2c08.png  8-bit truecolor
-    basn2c16.png 16-bit truecolor
-    basn3p01.png  1-bit paletted
-    basn3p02.png  2-bit paletted
-    basn3p04.png  4-bit paletted
-    basn3p08.png  8-bit paletted
-    basn4a08.png  8-bit gray with alpha
-    basn4a16.png 16-bit gray with alpha
-    basn6a08.png  8-bit RGBA
-    basn6a16.png 16-bit RGBA
-
-Here is the correct result of typing "pngtest -m *.png" in
-this directory:
-
-Testing basn0g01.png: PASS (524 zero samples)
- Filter 0 was used 32 times
-Testing basn0g02.png: PASS (448 zero samples)
- Filter 0 was used 32 times
-Testing basn0g04.png: PASS (520 zero samples)
- Filter 0 was used 32 times
-Testing basn0g08.png: PASS (3 zero samples)
- Filter 1 was used 9 times
- Filter 4 was used 23 times
-Testing basn0g16.png: PASS (1 zero samples)
- Filter 1 was used 1 times
- Filter 2 was used 31 times
-Testing basn2c08.png: PASS (6 zero samples)
- Filter 1 was used 5 times
- Filter 4 was used 27 times
-Testing basn2c16.png: PASS (592 zero samples)
- Filter 1 was used 1 times
- Filter 4 was used 31 times
-Testing basn3p01.png: PASS (512 zero samples)
- Filter 0 was used 32 times
-Testing basn3p02.png: PASS (448 zero samples)
- Filter 0 was used 32 times
-Testing basn3p04.png: PASS (544 zero samples)
- Filter 0 was used 32 times
-Testing basn3p08.png: PASS (4 zero samples)
- Filter 0 was used 32 times
-Testing basn4a08.png: PASS (32 zero samples)
- Filter 1 was used 1 times
- Filter 4 was used 31 times
-Testing basn4a16.png: PASS (64 zero samples)
- Filter 0 was used 1 times
- Filter 1 was used 2 times
- Filter 2 was used 1 times
- Filter 4 was used 28 times
-Testing basn6a08.png: PASS (160 zero samples)
- Filter 1 was used 1 times
- Filter 4 was used 31 times
-Testing basn6a16.png: PASS (1072 zero samples)
- Filter 1 was used 4 times
- Filter 4 was used 28 times
-libpng passes test
-
-Willem van Schaik
-<willem@schaik.com>
-October 1999
diff --git a/libpng.3 b/libpng.3
index d30c09d..8f70172 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "May 21, 2002"
+.TH LIBPNG 3 "May 25, 2002"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.3
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.4beta1
 .SH SYNOPSIS
 \fI\fB
 
@@ -342,6 +342,10 @@
 
 \fI\fB
 
+\fBpng_voidp png_malloc_warn (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
+
+\fI\fB
+
 \fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP
 
 \fI\fB
@@ -787,7 +791,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.2.3 - May 21, 2002
+ libpng version 1.2.4beta1 - May 25, 2002
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998-2002 Glenn Randers-Pehrson
@@ -3637,13 +3641,13 @@
 
 .SH IX. Y2K Compliance in libpng
 
-May 21, 2002
+May 25, 2002
 
 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.3 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.4beta1 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
@@ -3774,6 +3778,7 @@
  1.2.2               12    10202  12.so.0.1.2.2
  1.2.3rc1-6          12    10203  12.so.0.1.2.3rc1-6
  1.2.3               12    10203  12.so.0.1.2.3
+ 1.2.4beta1          13    10204  12.so.0.1.2.4beta1 
 
 Henceforth the source version will match the shared-library minor
 and patch numbers; the shared-library major version number will be
@@ -3831,7 +3836,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.2.3 - May 21, 2002:
+Libpng version 1.2.4beta1 - May 25, 2002:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
 
@@ -3848,7 +3853,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.3, May 21, 2002, are
+libpng versions 1.0.7, July 1, 2000, through 1.2.4beta1, May 25, 2002, are
 Copyright (c) 2000-2002 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
@@ -3940,7 +3945,7 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-May 21, 2002
+May 25, 2002
 
 .\" end of man page
 
diff --git a/libpng.txt b/libpng.txt
index 9bac757..2304ab1 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.3 - May 21, 2002
+ libpng version 1.2.4beta1 - May 25, 2002
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998-2002 Glenn Randers-Pehrson
@@ -2850,13 +2850,13 @@
 
 IX. Y2K Compliance in libpng
 
-May 21, 2002
+May 25, 2002
 
 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.3 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.4beta1 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 e5c91e0..8dcba8f 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "May 21, 2002"
+.TH LIBPNGPF 3 "May 25, 2002"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.3
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.4beta1
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
@@ -411,7 +411,7 @@
 
 \fI\fB
 
-\fBvoid png_write_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fIcolor_type\fP\fB);\fP
+\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text)\fP\fB);\fP
 
 \fI\fB
 
diff --git a/png.5 b/png.5
index ab427a0..2d23a58 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "May 21, 2002"
+.TH PNG 5 "May 25, 2002"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
@@ -53,7 +53,7 @@
 The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson.
 See the specification for conditions of use and distribution.
 .LP
-The PNG-1.0 specification is copyright (c) 1996 Massachussets Institute of
+The PNG-1.0 specification is copyright (c) 1996 Massachusetts Institute of
 Technology.  See the specification for conditions of use and distribution.
 .LP
 .\" end of man page
diff --git a/png.c b/png.c
index 8d79ba0..0a3960c 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.2.3 - May 21, 2002
+ * libpng version 1.2.4beta1 - May 25, 2002
  * Copyright (c) 1998-2002 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_3 Your_png_h_is_not_version_1_2_3;
+typedef version_1_2_4beta1 Your_png_h_is_not_version_1_2_4beta1;
 
 /* 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.3";
+const char png_libpng_ver[18] = "1.2.4beta1";
 
 /* png_sig was changed to a function in version 1.0.5c */
 /* Place to hold the signature string for a PNG file. */
@@ -663,7 +663,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.3 - May 21, 2002\n\
+   return ((png_charp) "\n libpng version 1.2.4beta1 - May 25, 2002\n\
    Copyright (c) 1998-2002 Glenn Randers-Pehrson\n\
    Copyright (c) 1996-1997 Andreas Dilger\n\
    Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
@@ -681,8 +681,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.3");
-   return((png_charp) "1.2.3");
+      return((png_charp) "1.2.4beta1");
+   return((png_charp) "1.2.4beta1");
 }
 
 png_charp PNGAPI
@@ -732,7 +732,7 @@
 png_access_version_number(void)
 {
    /* Version of *.c files used when building libpng */
-   return((png_uint_32) 10203L);
+   return((png_uint_32) 10204L);
 }
 
 
diff --git a/png.h b/png.h
index 3e6d333..a62b75f 100644
--- a/png.h
+++ b/png.h
@@ -1,6 +1,6 @@
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.2.3 - May 21, 2002
+ * libpng version 1.2.4beta1 - May 25, 2002
  * Copyright (c) 1998-2002 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.3 - May 21, 2002: Glenn
+ *  libpng versions 0.97, January 1998, through 1.2.4beta1 - May 25, 2002: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -88,6 +88,7 @@
  *    1.2.2                   12    10202  12.so.0.1.2.2
  *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6
  *    1.2.3                   12    10203  12.so.0.1.2.3
+ *    1.2.4beta1              13    10204  12.so.0.1.2.4beta1 
  *
  *    Henceforth the source version will match the shared-library major
  *    and minor numbers; the shared-library major version number will be
@@ -117,7 +118,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.3, May 21, 2002, are
+ * libpng versions 1.0.7, July 1, 2000, through 1.2.4beta1, May 25, 2002, are
  * Copyright (c) 2000-2002 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
@@ -222,13 +223,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    May 21, 2002
+ *    May 25, 2002
  *
  *    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.3 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.2.4beta1 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
@@ -284,7 +285,7 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.2.3"
+#define PNG_LIBPNG_VER_STRING "1.2.4beta1"
 
 #define PNG_LIBPNG_VER_SONUM   0
 #define PNG_LIBPNG_VER_DLLNUM  %DLLNUM%
@@ -292,11 +293,11 @@
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   2
-#define PNG_LIBPNG_VER_RELEASE 3
+#define PNG_LIBPNG_VER_RELEASE 4
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
 
-#define PNG_LIBPNG_VER_BUILD  0
+#define PNG_LIBPNG_VER_BUILD  1
 
 #define PNG_LIBPNG_BUILD_ALPHA    1
 #define PNG_LIBPNG_BUILD_BETA     2
@@ -304,14 +305,14 @@
 #define PNG_LIBPNG_BUILD_STABLE   4
 #define PNG_LIBPNG_BUILD_TYPEMASK 7
 #define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with STABLE only */
-#define PNG_LIBPNG_BUILD_TYPE 4
+#define PNG_LIBPNG_BUILD_TYPE 2
 
 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
  * We must not include leading zeros.
  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release */
-#define PNG_LIBPNG_VER 10203 /* 1.2.3 */
+#define PNG_LIBPNG_VER 10204 /* 1.2.4 */
 
 #ifndef PNG_VERSION_INFO_ONLY
 
@@ -1260,13 +1261,22 @@
 
    png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */
 
+#if defined(PNG_READ_DITHER_SUPPORTED)
+/* The following three members were added at version 1.2.4 */
+   png_bytep dither_sort;            /* working sort array */
+   png_bytep index_to_palette;       /* where the original index currently is */
+                                     /* in the palette */
+   png_bytep palette_to_index;       /* which original index points to this */
+                                     /* palette color */
+#endif
+
 };
 
 
 /* This prevents a compiler error in png.c if png.c and png.h are both at
-   version 1.2.3
+   version 1.2.4beta1
  */
-typedef png_structp version_1_2_3;
+typedef png_structp version_1_2_4beta1;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -1815,6 +1825,10 @@
 extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
    png_uint_32 size));
 
+/* Added at libpng version 1.2.4 */
+extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr,
+   png_uint_32 size));
+
 /* frees a pointer allocated by png_malloc() */
 extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
 
@@ -2388,7 +2402,7 @@
 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
 
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.2.3 - May 21, 2002 (header)\n"
+   " libpng version 1.2.4beta1 - May 25, 2002 (header)\n"
 
 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
 /* With these routines we avoid an integer divide, which will be slower on
@@ -2846,6 +2860,11 @@
    png_charp text));
 #endif
 
+#if defined(PNG_TEXT_SUPPORTED)  /* Added at version 1.2.4 */
+PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
+   png_infop info_ptr, png_textp text_ptr, int num_text));
+#endif
+
 #if defined(PNG_WRITE_oFFs_SUPPORTED)
 PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
    png_int_32 x_offset, png_int_32 y_offset, int unit_type));
diff --git a/pngasmrd.h b/pngasmrd.h
index 2cb38e2..b1042f9 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.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 2002 Glenn Randers-Pehrson
  *
diff --git a/pngconf.h b/pngconf.h
index 9f2acea..c356eea 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,6 +1,6 @@
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngerror.c b/pngerror.c
index aeb06e5..cca68f1 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pnggccrd.c b/pnggccrd.c
index e6560bc..685f5e2 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.3 - May 21, 2002
+ * libpng version 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngget.c b/pngget.c
index cd9350a..4e41ddc 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngmem.c b/pngmem.c
index 7dbe403..2341bb6 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -110,12 +110,12 @@
  * result, we would be truncating potentially larger memory requests
  * (which should cause a fatal error) and introducing major problems.
  */
+
 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 (NULL);
 
@@ -399,7 +399,6 @@
    }
 }
 
-
 /* Allocate memory.  For reasonable files, size should never exceed
    64K.  However, zlib may allocate more then 64K if you don't tell
    it not to.  See zconf.h and png.h for more information.  zlib does
@@ -410,13 +409,14 @@
 png_malloc(png_structp png_ptr, png_uint_32 size)
 {
    png_voidp ret;
+
    if (png_ptr == NULL || size == 0)
       return (NULL);
 
 #ifdef PNG_USER_MEM_SUPPORTED
    if(png_ptr->malloc_fn != NULL)
    {
-       ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+       ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
        if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
           png_error(png_ptr, "Out of Memory!");
        return (ret);
@@ -424,6 +424,7 @@
    else
        return (png_malloc_default(png_ptr, size));
 }
+
 png_voidp PNGAPI
 png_malloc_default(png_structp png_ptr, png_uint_32 size)
 {
@@ -493,6 +494,22 @@
 
 #endif /* Not Borland DOS special memory handler */
 
+/* This function was added at libpng version 1.3.0.  The png_malloc_warn()
+ * function will issue a png_warning and return NULL instead of issuing a
+ * png_error, if it fails to allocate the requested memory.
+ */
+png_voidp PNGAPI
+png_malloc_warn(png_structp png_ptr, png_uint_32 size)
+{
+   png_voidp ptr;
+   png_uint_32 save_flags=png_ptr->flags;
+
+   png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
+   ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
+   png_ptr->flags=save_flags;
+   return(ptr);
+}
+
 png_voidp PNGAPI
 png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
    png_uint_32 length)
diff --git a/pngpread.c b/pngpread.c
index 452854d..897fc32 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -1051,6 +1051,7 @@
       png_textp text_ptr;
       png_charp text;
       png_charp key;
+      int ret;
 
       if (png_ptr->buffer_size < 4)
       {
@@ -1083,10 +1084,13 @@
 #endif
       text_ptr->text = text;
 
-      png_set_text(png_ptr, info_ptr, text_ptr, 1);
+      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
       png_free(png_ptr, key);
       png_free(png_ptr, text_ptr);
+
+      if (ret)
+        png_warning(png_ptr, "Insufficient memory to store text chunk.");
    }
 }
 #endif
@@ -1268,10 +1272,13 @@
 #endif
       text_ptr->text = text;
 
-      png_set_text(png_ptr, info_ptr, text_ptr, 1);
+      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
       png_free(png_ptr, key);
       png_free(png_ptr, text_ptr);
+
+      if (ret)
+        png_warning(png_ptr, "Insufficient memory to store text chunk.");
    }
 }
 #endif
@@ -1332,6 +1339,7 @@
       png_charp lang;
       png_charp lang_key;
       png_charp text;
+      int ret;
 
       if (png_ptr->buffer_size < 4)
       {
@@ -1377,9 +1385,11 @@
       text_ptr->text_length = 0;
       text_ptr->itxt_length = png_strlen(text);
 
-      png_set_text(png_ptr, info_ptr, text_ptr, 1);
+      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
       png_free(png_ptr, text_ptr);
+      if (ret)
+        png_warning(png_ptr, "Insufficient memory to store iTXt chunk.");
    }
 }
 #endif
diff --git a/pngread.c b/pngread.c
index 7d672a1..1a9e711 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -795,7 +795,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.3
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.4beta1
  */
 
 void PNGAPI
@@ -844,7 +844,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.3
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.4beta1
  */
 void PNGAPI
 png_read_image(png_structp png_ptr, png_bytepp image)
diff --git a/pngrio.c b/pngrio.c
index 7e6ed2a..7a358c9 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngrtran.c b/pngrtran.c
index b4dd25d..a04f306 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.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -167,15 +167,14 @@
             Perhaps not the best solution, but good enough. */
 
          int i;
-         png_bytep sort;
 
          /* initialize an array to sort colors */
-         sort = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette
-            * sizeof (png_byte)));
+         png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
+            (png_uint_32)(num_palette * sizeof (png_byte)));
 
-         /* initialize the sort array */
+         /* initialize the dither_sort array */
          for (i = 0; i < num_palette; i++)
-            sort[i] = (png_byte)i;
+            png_ptr->dither_sort[i] = (png_byte)i;
 
          /* Find the least used palette entries by starting a
             bubble sort, and running it until we have sorted
@@ -191,13 +190,14 @@
             done = 1;
             for (j = 0; j < i; j++)
             {
-               if (histogram[sort[j]] < histogram[sort[j + 1]])
+               if (histogram[png_ptr->dither_sort[j]]
+                   < histogram[png_ptr->dither_sort[j + 1]])
                {
                   png_byte t;
 
-                  t = sort[j];
-                  sort[j] = sort[j + 1];
-                  sort[j + 1] = t;
+                  t = png_ptr->dither_sort[j];
+                  png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1];
+                  png_ptr->dither_sort[j + 1] = t;
                   done = 0;
                }
             }
@@ -214,11 +214,11 @@
                move the others */
             for (i = 0; i < maximum_colors; i++)
             {
-               if ((int)sort[i] >= maximum_colors)
+               if ((int)png_ptr->dither_sort[i] >= maximum_colors)
                {
                   do
                      j--;
-                  while ((int)sort[j] >= maximum_colors);
+                  while ((int)png_ptr->dither_sort[j] >= maximum_colors);
                   palette[i] = palette[j];
                }
             }
@@ -232,13 +232,13 @@
             for (i = 0; i < maximum_colors; i++)
             {
                /* only move the colors we need to */
-               if ((int)sort[i] >= maximum_colors)
+               if ((int)png_ptr->dither_sort[i] >= maximum_colors)
                {
                   png_color tmp_color;
 
                   do
                      j--;
-                  while ((int)sort[j] >= maximum_colors);
+                  while ((int)png_ptr->dither_sort[j] >= maximum_colors);
 
                   tmp_color = palette[j];
                   palette[j] = palette[i];
@@ -276,7 +276,8 @@
                }
             }
          }
-         png_free(png_ptr, sort);
+         png_free(png_ptr, png_ptr->dither_sort);
+         png_ptr->dither_sort=NULL;
       }
       else
       {
@@ -291,23 +292,22 @@
          int i;
          int max_d;
          int num_new_palette;
+         png_dsortp t;
          png_dsortpp hash;
-         png_bytep index_to_palette;
-            /* where the original index currently is in the palette */
-         png_bytep palette_to_index;
-            /* which original index points to this palette color */
+
+         t=NULL;
 
          /* initialize palette index arrays */
-         index_to_palette = (png_bytep)png_malloc(png_ptr,
+         png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
             (png_uint_32)(num_palette * sizeof (png_byte)));
-         palette_to_index = (png_bytep)png_malloc(png_ptr,
+         png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
             (png_uint_32)(num_palette * sizeof (png_byte)));
 
          /* initialize the sort array */
          for (i = 0; i < num_palette; i++)
          {
-            index_to_palette[i] = (png_byte)i;
-            palette_to_index[i] = (png_byte)i;
+            png_ptr->index_to_palette[i] = (png_byte)i;
+            png_ptr->palette_to_index[i] = (png_byte)i;
          }
 
          hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
@@ -342,18 +342,22 @@
 
                   if (d <= max_d)
                   {
-                     png_dsortp t;
 
-                     t = (png_dsortp)png_malloc(png_ptr, (png_uint_32)(sizeof
-                         (png_dsort)));
+                     t = (png_dsortp)png_malloc_warn(png_ptr,
+                         (png_uint_32)(sizeof(png_dsort)));
+                     if (t == NULL)
+                         break;
                      t->next = hash[d];
                      t->left = (png_byte)i;
                      t->right = (png_byte)j;
                      hash[d] = t;
                   }
                }
+               if (t == NULL)
+                  break;
             }
 
+            if (t != NULL)
             for (i = 0; i <= max_d; i++)
             {
                if (hash[i] != NULL)
@@ -362,8 +366,10 @@
 
                   for (p = hash[i]; p; p = p->next)
                   {
-                     if ((int)index_to_palette[p->left] < num_new_palette &&
-                        (int)index_to_palette[p->right] < num_new_palette)
+                     if ((int)png_ptr->index_to_palette[p->left]
+                        < num_new_palette &&
+                        (int)png_ptr->index_to_palette[p->right]
+                        < num_new_palette)
                      {
                         int j, next_j;
 
@@ -379,7 +385,8 @@
                         }
 
                         num_new_palette--;
-                        palette[index_to_palette[j]] = palette[num_new_palette];
+                        palette[png_ptr->index_to_palette[j]]
+                          = palette[num_new_palette];
                         if (!full_dither)
                         {
                            int k;
@@ -387,23 +394,23 @@
                            for (k = 0; k < num_palette; k++)
                            {
                               if (png_ptr->dither_index[k] ==
-                                 index_to_palette[j])
+                                 png_ptr->index_to_palette[j])
                                  png_ptr->dither_index[k] =
-                                    index_to_palette[next_j];
+                                    png_ptr->index_to_palette[next_j];
                               if ((int)png_ptr->dither_index[k] ==
                                  num_new_palette)
                                  png_ptr->dither_index[k] =
-                                    index_to_palette[j];
+                                    png_ptr->index_to_palette[j];
                            }
                         }
 
-                        index_to_palette[palette_to_index[num_new_palette]] =
-                           index_to_palette[j];
-                        palette_to_index[index_to_palette[j]] =
-                           palette_to_index[num_new_palette];
+                        png_ptr->index_to_palette[png_ptr->palette_to_index
+                           [num_new_palette]] = png_ptr->index_to_palette[j];
+                        png_ptr->palette_to_index[png_ptr->index_to_palette[j]]
+                           = png_ptr->palette_to_index[num_new_palette];
 
-                        index_to_palette[j] = (png_byte)num_new_palette;
-                        palette_to_index[num_new_palette] = (png_byte)j;
+                        png_ptr->index_to_palette[j] = (png_byte)num_new_palette;
+                        png_ptr->palette_to_index[num_new_palette] = (png_byte)j;
                      }
                      if (num_new_palette <= maximum_colors)
                         break;
@@ -420,8 +427,6 @@
                   png_dsortp p = hash[i];
                   while (p)
                   {
-                     png_dsortp t;
-
                      t = p->next;
                      png_free(png_ptr, p);
                      p = t;
@@ -432,8 +437,10 @@
             max_d += 96;
          }
          png_free(png_ptr, hash);
-         png_free(png_ptr, palette_to_index);
-         png_free(png_ptr, index_to_palette);
+         png_free(png_ptr, png_ptr->palette_to_index);
+         png_free(png_ptr, png_ptr->index_to_palette);
+         png_ptr->palette_to_index=NULL;
+         png_ptr->index_to_palette=NULL;
       }
       num_palette = maximum_colors;
    }
diff --git a/pngrutil.c b/pngrutil.c
index 4432238..fbcb64d 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -200,7 +200,12 @@
             if (text ==  NULL)
             {
                text_size = prefix_size + sizeof(msg) + 1;
-               text = (png_charp)png_malloc(png_ptr, text_size);
+               text = (png_charp)png_malloc_warn(png_ptr, text_size);
+               if (text ==  NULL)
+                 {
+                    png_free(png_ptr,chunkdata);
+                    png_error(png_ptr,"Not enough memory to decompress chunk");
+                 }
                png_memcpy(text, chunkdata, prefix_size);
             }
 
@@ -218,7 +223,12 @@
             {
                text_size = prefix_size +
                    png_ptr->zbuf_size - png_ptr->zstream.avail_out;
-               text = (png_charp)png_malloc(png_ptr, text_size + 1);
+               text = (png_charp)png_malloc_warn(png_ptr, text_size + 1);
+               if (text ==  NULL)
+                 {
+                    png_free(png_ptr,chunkdata);
+                    png_error(png_ptr,"Not enough memory to decompress chunk.");
+                 }
                png_memcpy(text + prefix_size, png_ptr->zbuf,
                     text_size - prefix_size);
                png_memcpy(text, chunkdata, prefix_size);
@@ -229,8 +239,15 @@
                png_charp tmp;
 
                tmp = text;
-               text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size +
+               text = (png_charp)png_malloc_warn(png_ptr,
+                  (png_uint_32)(text_size +
                   png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
+               if (text == NULL)
+               {
+                  png_free(png_ptr, tmp);
+                  png_free(png_ptr, chunkdata);
+                  png_error(png_ptr,"Not enough memory to decompress chunk..");
+               }
                png_memcpy(text, tmp, text_size);
                png_free(png_ptr, tmp);
                png_memcpy(text + text_size, png_ptr->zbuf,
@@ -269,7 +286,12 @@
          text_size=prefix_size;
          if (text ==  NULL)
          {
-            text = (png_charp)png_malloc(png_ptr, text_size+1);
+            text = (png_charp)png_malloc_warn(png_ptr, text_size+1);
+            if (text == NULL)
+              {
+                png_free(png_ptr, chunkdata);
+                png_error(png_ptr,"Not enough memory for text.");
+              }
             png_memcpy(text, chunkdata, prefix_size);
          }
          *(text + text_size) = 0x00;
@@ -1542,7 +1564,12 @@
 
    png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n",
       length + 1);
-   purpose = (png_charp)png_malloc(png_ptr, length + 1);
+   purpose = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (purpose == NULL)
+     {
+       png_warning(png_ptr, "No memory for pCAL purpose.");
+       return;
+     }
    slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)purpose, slength);
 
@@ -1597,8 +1624,14 @@
       /* Empty loop to move past the units string. */ ;
 
    png_debug(3, "Allocating pCAL parameters array\n");
-   params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams
+   params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams
       *sizeof(png_charp))) ;
+   if (params == NULL)
+     {
+       png_free(png_ptr, purpose);
+       png_warning(png_ptr, "No memory for pCAL params.");
+       return;
+     }
 
    /* Get pointers to the start of each parameter string. */
    for (i = 0; i < (int)nparams; i++)
@@ -1662,7 +1695,12 @@
 
    png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n",
       length + 1);
-   buffer = (png_charp)png_malloc(png_ptr, length + 1);
+   buffer = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (buffer == NULL)
+     {
+       png_warning(png_ptr, "Out of memory while processing sCAL chunk");
+       return;
+     }
    slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)buffer, slength);
 
@@ -1685,7 +1723,12 @@
    }
 #else
 #ifdef PNG_FIXED_POINT_SUPPORTED
-   swidth = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1);
+   swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
+   if (swidth == NULL)
+     {
+       png_warning(png_ptr, "Out of memory while processing sCAL chunk width");
+       return;
+     }
    png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
 #endif
 #endif
@@ -1703,7 +1746,12 @@
    }
 #else
 #ifdef PNG_FIXED_POINT_SUPPORTED
-   sheight = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1);
+   sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
+   if (swidth == NULL)
+     {
+       png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
+       return;
+     }
    png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
 #endif
 #endif
@@ -1793,6 +1841,7 @@
    png_charp text;
    png_uint_32 skip = 0;
    png_size_t slength;
+   int ret;
 
    png_debug(1, "in png_handle_tEXt\n");
 
@@ -1811,7 +1860,12 @@
    }
 #endif
 
-   key = (png_charp)png_malloc(png_ptr, length + 1);
+   key = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (key == NULL)
+   {
+     png_warning(png_ptr, "No memory to process text chunk.");
+     return;
+   }
    slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)key, slength);
 
@@ -1829,7 +1883,13 @@
    if (text != key + slength)
       text++;
 
-   text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   if (text_ptr == NULL)
+   {
+     png_warning(png_ptr, "Not enough memory to process text chunk.");
+     png_free(png_ptr, key);
+     return;
+   }
    text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
    text_ptr->key = key;
 #ifdef PNG_iTXt_SUPPORTED
@@ -1840,10 +1900,12 @@
    text_ptr->text = text;
    text_ptr->text_length = png_strlen(text);
 
-   png_set_text(png_ptr, info_ptr, text_ptr, 1);
+   ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
    png_free(png_ptr, key);
    png_free(png_ptr, text_ptr);
+   if (ret)
+     png_warning(png_ptr, "Insufficient memory to process text chunk.");
 }
 #endif
 
@@ -1856,6 +1918,7 @@
    png_charp chunkdata;
    png_charp text;
    int comp_type;
+   int ret;
    png_size_t slength, prefix_len, data_len;
 
    png_debug(1, "in png_handle_zTXt\n");
@@ -1876,8 +1939,13 @@
    }
 #endif
 
-   chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
-     slength = (png_size_t)length;
+   chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (chunkdata == NULL)
+   {
+     png_warning(png_ptr,"Out of memory processing zTXt chunk.");
+     return;
+   }
+   slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
    if (png_crc_finish(png_ptr, 0))
    {
@@ -1911,7 +1979,13 @@
    chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata,
                                     (png_size_t)length, prefix_len, &data_len);
 
-   text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   if (text_ptr == NULL)
+   {
+     png_warning(png_ptr,"Not enough memory to process zTXt chunk.");
+     png_free(png_ptr, chunkdata);
+     return;
+   }
    text_ptr->compression = comp_type;
    text_ptr->key = chunkdata;
 #ifdef PNG_iTXt_SUPPORTED
@@ -1922,10 +1996,12 @@
    text_ptr->text = chunkdata + prefix_len;
    text_ptr->text_length = data_len;
 
-   png_set_text(png_ptr, info_ptr, text_ptr, 1);
+   ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
    png_free(png_ptr, text_ptr);
    png_free(png_ptr, chunkdata);
+   if (ret)
+     png_error(png_ptr, "Insufficient memory to store zTXt chunk.");
 }
 #endif
 
@@ -1939,6 +2015,7 @@
    png_charp key, lang, text, lang_key;
    int comp_flag;
    int comp_type = 0;
+   int ret;
    png_size_t slength, prefix_len, data_len;
 
    png_debug(1, "in png_handle_iTXt\n");
@@ -1960,7 +2037,12 @@
    }
 #endif
 
-   chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
+   chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (chunkdata == NULL)
+   {
+     png_warning(png_ptr, "No memory to process iTXt chunk.");
+     return;
+   }
    slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
    if (png_crc_finish(png_ptr, 0))
@@ -2006,7 +2088,13 @@
           (size_t)length, prefix_len, &data_len);
    else
        data_len=png_strlen(chunkdata + prefix_len);
-   text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   if (text_ptr == NULL)
+   {
+     png_warning(png_ptr,"Not enough memory to process iTXt chunk.");
+     png_free(png_ptr, chunkdata);
+     return;
+   }
    text_ptr->compression = (int)comp_flag + 1;
    text_ptr->lang_key = chunkdata+(lang_key-key);
    text_ptr->lang = chunkdata+(lang-key);
@@ -2015,10 +2103,12 @@
    text_ptr->key = chunkdata;
    text_ptr->text = chunkdata + prefix_len;
 
-   png_set_text(png_ptr, info_ptr, text_ptr, 1);
+   ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
    png_free(png_ptr, text_ptr);
    png_free(png_ptr, chunkdata);
+   if (ret)
+     png_error(png_ptr, "Insufficient memory to store iTXt chunk.");
 }
 #endif
 
@@ -2084,7 +2174,10 @@
              if (!(png_ptr->chunk_name[0] & 0x20))
                 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
                      HANDLE_CHUNK_ALWAYS)
+                 {
+                   png_free(png_ptr, chunk.data);
                    png_chunk_error(png_ptr, "unknown critical chunk");
+                 }
              png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
           }
        }
diff --git a/pngset.c b/pngset.c
index 7771080..22d3aac 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -216,8 +216,13 @@
    png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
 #endif
    /* Changed from info->num_palette to 256 in version 1.2.1 */
-   png_ptr->hist = (png_uint_16p)png_malloc(png_ptr,
+   png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
       (png_uint_32)(256 * sizeof (png_uint_16)));
+   if (png_ptr->hist == NULL)
+     {
+       png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
+       return;
+     }
 
    for (i = 0; i < info_ptr->num_palette; i++)
        png_ptr->hist[i] = hist[i];
@@ -358,7 +363,12 @@
 
    length = png_strlen(purpose) + 1;
    png_debug1(3, "allocating purpose for info (%lu bytes)\n", length);
-   info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length);
+   info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
+   if (info_ptr->pcal_purpose == NULL)
+     {
+       png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
+       return;
+     }
    png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
 
    png_debug(3, "storing X0, X1, type, and nparams in info\n");
@@ -369,11 +379,21 @@
 
    length = png_strlen(units) + 1;
    png_debug1(3, "allocating units for info (%lu bytes)\n", length);
-   info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length);
+   info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
+   if (info_ptr->pcal_units == NULL)
+     {
+       png_warning(png_ptr, "Insufficient memory for pCAL units.");
+       return;
+     }
    png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
 
-   info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr,
+   info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
       (png_uint_32)((nparams + 1) * sizeof(png_charp)));
+   if (info_ptr->pcal_params == NULL)
+     {
+       png_warning(png_ptr, "Insufficient memory for pCAL params.");
+       return;
+     }
 
    info_ptr->pcal_params[nparams] = NULL;
 
@@ -381,7 +401,12 @@
    {
       length = png_strlen(params[i]) + 1;
       png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length);
-      info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length);
+      info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
+      if (info_ptr->pcal_params[i] == NULL)
+        {
+          png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
+          return;
+        }
       png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
    }
 
@@ -628,13 +653,23 @@
 png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
    int num_text)
 {
+   int ret;
+   ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
+   if (ret)
+     png_error(png_ptr, "Insufficient memory to store text");
+}
+
+int /* PRIVATE */
+png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
+   int num_text)
+{
    int i;
 
    png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
       "text" : (png_const_charp)png_ptr->chunk_name));
 
    if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
-      return;
+      return(0);
 
    /* Make sure we have enough space in the "text" array in info_struct
     * to hold all of the incoming text_ptr objects.
@@ -649,8 +684,13 @@
          old_max = info_ptr->max_text;
          info_ptr->max_text = info_ptr->num_text + num_text + 8;
          old_text = info_ptr->text;
-         info_ptr->text = (png_textp)png_malloc(png_ptr,
+         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
             (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
+         if (info_ptr->text == NULL)
+           {
+             png_free(png_ptr, old_text);
+             return(1);
+           }
          png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
             sizeof(png_text)));
          png_free(png_ptr, old_text);
@@ -659,8 +699,10 @@
       {
          info_ptr->max_text = num_text + 8;
          info_ptr->num_text = 0;
-         info_ptr->text = (png_textp)png_malloc(png_ptr,
+         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
             (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
+         if (info_ptr->text == NULL)
+           return(1);
 #ifdef PNG_FREE_ME_SUPPORTED
          info_ptr->free_me |= PNG_FREE_TEXT;
 #endif
@@ -720,8 +762,10 @@
          textp->compression = text_ptr[i].compression;
       }
 
-      textp->key = (png_charp)png_malloc(png_ptr,
+      textp->key = (png_charp)png_malloc_warn(png_ptr,
          (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
+      if (textp->key == NULL)
+        return(1);
       png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
          (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4),
          (int)textp->key);
@@ -772,6 +816,7 @@
       info_ptr->num_text++;
       png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
    }
+   return(0);
 }
 #endif
 
@@ -839,8 +884,13 @@
     png_sPLT_tp np;
     int i;
 
-    np = (png_sPLT_tp)png_malloc(png_ptr,
+    np = (png_sPLT_tp)png_malloc_warn(png_ptr,
         (info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t));
+    if (np == NULL)
+    {
+      png_warning(png_ptr, "No memory for splt palettes.");
+      return;
+    }
 
     png_memcpy(np, info_ptr->splt_palettes,
            info_ptr->splt_palettes_num * sizeof(png_sPLT_t));
@@ -883,9 +933,14 @@
     if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
         return;
 
-    np = (png_unknown_chunkp)png_malloc(png_ptr,
+    np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
         (info_ptr->unknown_chunks_num + num_unknowns) *
         sizeof(png_unknown_chunk));
+    if (np == NULL)
+    {
+       png_warning(png_ptr, "Out of memory while processing unknown chunk.");
+       return;
+    }
 
     png_memcpy(np, info_ptr->unknown_chunks,
            info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk));
@@ -899,11 +954,16 @@
 
         png_strcpy((png_charp)to->name, (png_charp)from->name);
         to->data = (png_bytep)png_malloc(png_ptr, from->size);
-        png_memcpy(to->data, from->data, from->size);
-        to->size = from->size;
+        if (to->data == NULL)
+           png_warning(png_ptr, "Out of memory while processing unknown chunk.");
+        else
+        {
+          png_memcpy(to->data, from->data, from->size);
+          to->size = from->size;
 
-        /* note our location in the read or write sequence */
-        to->location = (png_byte)(png_ptr->mode & 0xff);
+          /* note our location in the read or write sequence */
+          to->location = (png_byte)(png_ptr->mode & 0xff);
+        }
     }
 
     info_ptr->unknown_chunks = np;
diff --git a/pngtest.c b/pngtest.c
index c67672f..48b0c3e 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -1512,4 +1512,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_3 your_png_h_is_not_version_1_2_3;
+typedef version_1_2_4beta1 your_png_h_is_not_version_1_2_4beta1;
diff --git a/pngtrans.c b/pngtrans.c
index fd34bf6..c127959 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.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngvcrd.c b/pngvcrd.c
index eafa5c3..0bbdb87 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng version 1.2.3 - May 21, 2002
+ * libpng version 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngwio.c b/pngwio.c
index 7a46719..96047d2 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngwrite.c b/pngwrite.c
index bc302be..17c048f 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngwtran.c b/pngwtran.c
index 07ebaca..0c1ab2a 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.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngwutil.c b/pngwutil.c
index f84f931..a5f44ed 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.2.3 - May 21, 2002
+ * libpng 1.2.4beta1 - May 25, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/projects/msvc/README.txt b/projects/msvc/README.txt
index d215d78..09e67ba 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.3 (May 21, 2002) and zlib
+libpng 1.2.4beta1 (May 25, 2002) 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 233957d..d7f754f 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.3
+;Version 1.2.4beta1
   png_build_grayscale_palette  @1
   png_check_sig        @2
   png_chunk_error      @3
@@ -216,3 +216,5 @@
 ; Added at version 1.2.2 and deleted from 1.2.3
 ; png_zalloc @195
 ; png_zfree @196
+; Added at version 1.2.4
+  png_malloc_warn @195
diff --git a/projects/netware.txt b/projects/netware.txt
index 806a954..87cb249 100644
--- a/projects/netware.txt
+++ b/projects/netware.txt
@@ -1,6 +1,6 @@
 A set of project files is available for Netware.  Get
-libpng-1.2.3-project-netware.zip from a libpng distribution
+libpng-1.2.4beta1-project-netware.zip from a libpng distribution
 site such as http://libpng.sourceforge.net
 
 Put the zip file in this directory (projects) and then run
-"unzip -a libpng-1.2.3-project-netware.zip"
+"unzip -a libpng-1.2.4beta1-project-netware.zip"
diff --git a/projects/wince.txt b/projects/wince.txt
index e89b346..8819ffb 100644
--- a/projects/wince.txt
+++ b/projects/wince.txt
@@ -1,6 +1,6 @@
 A set of project files is available for WinCE.  Get
-libpng-1.2.3-project-wince.zip from a libpng distribution
+libpng-1.2.4beta1-project-wince.zip from a libpng distribution
 site such as http://libpng.sourceforge.net
 
 Put the zip file in this directory (projects) and then run
-"unzip -a libpng-1.2.3-project-wince.zip"
+"unzip -a libpng-1.2.4beta1-project-wince.zip"
diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in
index ebbfe7f..ca91b49 100755
--- a/scripts/libpng-config-head.in
+++ b/scripts/libpng-config-head.in
@@ -8,7 +8,7 @@
 
 # Modeled after libxml-config.
 
-version=1.2.3
+version=1.2.4beta1
 prefix=""
 cppflags=""
 cflags=""
diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in
index 81e3710..84044dc 100644
--- a/scripts/libpng.pc.in
+++ b/scripts/libpng.pc.in
@@ -6,6 +6,6 @@
 
 Name: libpng12
 Description: Loads and saves PNG files
-Version: 1.2.3
+Version: 1.2.4beta1
 Libs: -L${libdir} -lpng12 -lz -lm
 Cflags: -I${includedir}/libpng12
diff --git a/scripts/makefile.32sunu b/scripts/makefile.32sunu
index 58efd83..492f65e 100644
--- a/scripts/makefile.32sunu
+++ b/scripts/makefile.32sunu
@@ -33,7 +33,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
@@ -47,14 +47,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -67,7 +67,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -118,12 +118,10 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm $(DI)/libpng
-	(cd $(DI); ln -f -s $(LIBNAME) libpng; \
-	ln -f -s $(LIBNAME)/* .)
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
@@ -134,8 +132,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.64sunu b/scripts/makefile.64sunu
index d6c89cd..e20b958 100644
--- a/scripts/makefile.64sunu
+++ b/scripts/makefile.64sunu
@@ -33,7 +33,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
@@ -47,14 +47,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -67,7 +67,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -118,12 +118,10 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm $(DI)/libpng
-	(cd $(DI); ln -f -s $(LIBNAME) libpng; \
-	ln -f -s $(LIBNAME)/* .)
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
@@ -134,8 +132,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.aix b/scripts/makefile.aix
index f5a75a5..519a552 100644
--- a/scripts/makefile.aix
+++ b/scripts/makefile.aix
@@ -17,7 +17,7 @@
 RM = rm -f
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 prefix=/usr/local
@@ -30,7 +30,7 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
diff --git a/scripts/makefile.atari b/scripts/makefile.atari
index bc4d570..9566d5d 100644
--- a/scripts/makefile.atari
+++ b/scripts/makefile.atari
@@ -20,7 +20,7 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index 90793c4..8c3bf8b 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -12,7 +12,7 @@
 ZLIBINC=/usr/local/include
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 ALIGN=
@@ -46,14 +46,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 LIBNAME=libpng12
 
@@ -65,7 +65,7 @@
 
 .SUFFIXES:      .c .o
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -106,8 +106,7 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
 	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
@@ -121,8 +120,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin
index d406afb..d82cef2 100644
--- a/scripts/makefile.cygwin
+++ b/scripts/makefile.cygwin
@@ -26,7 +26,7 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 
 DESTDIR=
@@ -79,7 +79,7 @@
 LIBNAME = libpng12
 PNGMAJ = 0
 PNGDLL = 12
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 SHAREDLIB=cygpng$(PNGDLL).dll
@@ -108,9 +108,9 @@
 # cosmetic: shortened strings:
 S =$(SRCDIR)
 D =$(DESTDIR)
-DB =$(D)/$(BINPATH)
-DI =$(D)/$(INCPATH)
-DL =$(D)/$(LIBPATH)
+DB =$(D)$(BINPATH)
+DI =$(D)$(INCPATH)
+DL =$(D)$(LIBPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -126,7 +126,7 @@
 %.pic.o : %.c
 	$(CC) -c $(CFLAGS) -o $@ $<
 
-all: all-static all-shared libpng.pc libpng-config
+all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
 
 # Make this to verify that "make [...] install" will do what you want.
 buildsetup-tell:
diff --git a/scripts/makefile.darwin b/scripts/makefile.darwin
index 05388ce..9e01643 100644
--- a/scripts/makefile.darwin
+++ b/scripts/makefile.darwin
@@ -23,7 +23,7 @@
 RANLIB=ranlib
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
@@ -38,14 +38,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -58,7 +58,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
 
-all: libpng.a $(LIBNAME).dylib pngtest
+all: libpng.a $(LIBNAME).dylib pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -101,8 +101,7 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
 	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 5c6a9d9..58ce427 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -16,14 +16,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 # Where the zlib library and include files are located
 #ZLIBLIB=/usr/local/lib
@@ -32,7 +32,7 @@
 ZLIBINC=../zlib
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
@@ -47,7 +47,7 @@
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: $(LIBNAME).so libpng.a pngtest
+all: $(LIBNAME).so libpng.a pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@  $(OBJS)
@@ -85,8 +85,7 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
 	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
@@ -100,8 +99,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index abde79c..0cf818a 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -15,7 +15,7 @@
 
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=gcc
@@ -71,14 +71,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -91,7 +91,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest pngtest-static
+all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
 
 libpng.pc:
 	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
@@ -100,7 +100,7 @@
 	( cat scripts/libpng-config-head.in; \
 	echo prefix=\"$(prefix)\"; \
 	echo cppflags=\"-I$(INCPATH)/$(LIBNAME) -DPNG_THREAD_UNSAFE_OK \
-	   -DPNG_USE_PNGGCCRD"; \
+	   -DPNG_USE_PNGGCCRD\"; \
 	echo cflags=\"\"; \
 	echo ldflags=\"\"; \
 	echo libs=\"-lpng12 -lz -lm\"; \
@@ -147,8 +147,7 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
 	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
@@ -162,8 +161,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc
index 6f78470..93b2d2c 100644
--- a/scripts/makefile.hpgcc
+++ b/scripts/makefile.hpgcc
@@ -33,7 +33,7 @@
 #RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
@@ -48,14 +48,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -68,7 +68,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).sl pngtest
+all: libpng.a $(LIBNAME).sl pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -108,8 +108,7 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
 	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
@@ -123,8 +122,7 @@
 
 install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).sl
+	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)* $(DL)/$(LIBNAME).sl
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index 4a30710..eeb497f 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -17,7 +17,7 @@
 RANLIB=ranlib
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
@@ -34,14 +34,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -54,7 +54,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) +z -o $@ $*.c
 
-all: libpng.a $(LIBNAME).sl pngtest
+all: libpng.a $(LIBNAME).sl pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@  $(OBJS)
@@ -94,8 +94,7 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
 	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
@@ -109,8 +108,7 @@
 
 install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).sl
+	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)* $(DL)/$(LIBNAME).sl
 	-@/bin/rm -f $(DL)/libpng.sl
 	-@/bin/rm -f $(DL)/libpng.sl.3
 	-@/bin/rm -f $(DL)/libpng.sl.3.*
diff --git a/scripts/makefile.knr b/scripts/makefile.knr
index 1e59fda..44ee538 100644
--- a/scripts/makefile.knr
+++ b/scripts/makefile.knr
@@ -19,7 +19,7 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index e8637ac..d101583 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -5,7 +5,7 @@
 
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=gcc
@@ -50,14 +50,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -70,7 +70,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -120,8 +120,7 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
 	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
@@ -135,8 +134,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
@@ -148,8 +146,7 @@
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.3.$(PNGMIN); \
 	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir \
-	$(DL)/pkgconfig; fi
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
 	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
 	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
 	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
diff --git a/scripts/makefile.macosx b/scripts/makefile.macosx
index 16c3cce..76fc57c 100644
--- a/scripts/makefile.macosx
+++ b/scripts/makefile.macosx
@@ -17,7 +17,7 @@
 CC=cc
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CFLAGS=-fno-common -I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
@@ -38,14 +38,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 #RANLIB=echo
 RANLIB=ranlib
@@ -54,7 +54,7 @@
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: libpng.a pngtest shared
+all: libpng.a pngtest shared libpng.pc libpng-config
 
 shared: $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
 
@@ -89,12 +89,10 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
-	(cd $(DI); ln -f -s $(LIBNAME) libpng; \
-	ln -f -s $(LIBNAME)/* .)
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
diff --git a/scripts/makefile.mips b/scripts/makefile.mips
index 320b185..f1a557d 100644
--- a/scripts/makefile.mips
+++ b/scripts/makefile.mips
@@ -14,7 +14,7 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
diff --git a/scripts/makefile.ne12bsd b/scripts/makefile.ne12bsd
index 6f47a5b..9321bdd 100644
--- a/scripts/makefile.ne12bsd
+++ b/scripts/makefile.ne12bsd
@@ -13,7 +13,7 @@
 
 LIB=	png12
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.2.3
+SHLIB_MINOR=	1.2.4beta1
 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.netbsd b/scripts/makefile.netbsd
index 7056478..dcd6cf7 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -13,7 +13,7 @@
 
 LIB=	png
 SHLIB_MAJOR=	3
-SHLIB_MINOR=	1.2.3
+SHLIB_MINOR=	1.2.4beta1
 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.openbsd b/scripts/makefile.openbsd
index 0edaee0..5d11ab1 100644
--- a/scripts/makefile.openbsd
+++ b/scripts/makefile.openbsd
@@ -7,7 +7,7 @@
 MANDIR= ${PREFIX}/man/cat
 
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.2.3
+SHLIB_MINOR=	1.2.4beta1
 
 LIB=	png
 SRCS=	png.c pngerror.c pnggccrd.c pngget.c pngmem.c pngpread.c \
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index 061e3e2..5288a70 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -24,7 +24,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
@@ -39,14 +39,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -59,7 +59,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -101,12 +101,10 @@
 	-@/bin/rm -f $(DI)/png.h
 	-@/bin/rm -f $(DI)/pngconf.h
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
-	(cd $(DI); ln -f -s $(LIBNAME) libpng; \
-	ln -f -s $(LIBNAME)/* .)
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
@@ -117,8 +115,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index d1c6e7e..b71f9ae 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -26,7 +26,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBS=$(LIBNAME).so.$(PNGVER)
 INCPATH=$(prefix)/include
@@ -40,14 +40,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 RANLIB=echo
 #RANLIB=ranlib
@@ -56,7 +56,7 @@
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: libpng.a $(LIBNAME).so.$(PNGVER) pngtest
+all: libpng.a $(LIBNAME).so.$(PNGVER) pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@  $(OBJS)
@@ -93,12 +93,10 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
-	(cd $(DI); ln -sf $(LIBNAME) libpng; \
-	ln -sf $(LIBNAME)/* .)
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
@@ -109,8 +107,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index 8c0d557..9098fe1 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -31,7 +31,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 RANLIB=echo
@@ -50,20 +50,20 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: libpng.a pngtest shared
+all: libpng.a pngtest shared libpng.pc libpng-config
 
 shared: $(LIBNAME).so.$(PNGVER)
 
@@ -105,8 +105,7 @@
 	$(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
-	(cd $(DI); ln -sf $(LIBNAME) libpng; \
-	ln -sf $(LIBNAME)/* .)
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
@@ -117,8 +116,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.so9 b/scripts/makefile.so9
index 249b168..a23e0fa 100644
--- a/scripts/makefile.so9
+++ b/scripts/makefile.so9
@@ -34,7 +34,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
@@ -49,14 +49,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -69,7 +69,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -120,8 +120,7 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
 	(cd $(DI); ln -f -s $(LIBNAME) libpng)
@@ -131,13 +130,11 @@
 	cp libpng.a $(DL)/$(LIBNAME).a
 	chmod 644 $(DL)/$(LIBNAME).a
 	-@/bin/rm -f $(DL)/libpng.a
-	(cd $(DI); ln -f -s $(LIBNAME) libpng; \
-	ln -f -s $(LIBNAME)/* .)
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
@@ -149,8 +146,7 @@
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.3.$(PNGMIN); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir \
-	$(DL)/pkgconfig; fi
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
 	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
 	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
 	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index 6e678b7..61debd2 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -30,7 +30,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.2.3
+PNGMIN = 1.2.4beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
@@ -45,14 +45,14 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
-DB=$(DESTDIR)/$(BINPATH)
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
-DM=$(DESTDIR)/$(MANPATH)
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -65,7 +65,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
@@ -117,12 +117,10 @@
 	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
 	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h \
-	$(DI)/$(LIBNAME)/pngconf.h
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
 	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
 	-@/bin/rm -f $(DI)/libpng
-	(cd $(DI); ln -f -s $(LIBNAME) libpng; \
-	ln -f -s $(LIBNAME)/* .)
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
@@ -133,8 +131,7 @@
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* \
-	$(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.3
 	-@/bin/rm -f $(DL)/libpng.so.3.*
diff --git a/scripts/makefile.std b/scripts/makefile.std
index 85ac06c..5d1f529 100644
--- a/scripts/makefile.std
+++ b/scripts/makefile.std
@@ -14,7 +14,7 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
diff --git a/scripts/makefile.sunos b/scripts/makefile.sunos
index 5f29960..70a6e88 100644
--- a/scripts/makefile.sunos
+++ b/scripts/makefile.sunos
@@ -14,7 +14,7 @@
 #    make install DESTDIR=/tmp/build/libpng
 #
 # If you're going to install into a temporary location
-# via DESTDIR, that location must already exist before
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
 # you execute make install.
 DESTDIR=
 
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index c39c2f0..5589463 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -7,8 +7,8 @@
 interface
 
 const
-  PNG_LIBPNG_VER_STRING = '1.2.3';
-  PNG_LIBPNG_VER        =  10203;
+  PNG_LIBPNG_VER_STRING = '1.2.4beta1';
+  PNG_LIBPNG_VER        =  10204;
 
 type
   png_uint_32 = Cardinal;
diff --git a/scripts/pngos2.def b/scripts/pngos2.def
index 2ad1e42..72d1d0b 100644
--- a/scripts/pngos2.def
+++ b/scripts/pngos2.def
@@ -2,7 +2,7 @@
 ; PNG.LIB module definition file for OS/2
 ;----------------------------------------
 
-; Version 1.2.3
+; Version 1.2.4beta1
 
 LIBRARY		PNG
 DESCRIPTION	"PNG image compression library for OS/2"
@@ -203,6 +203,9 @@
 ; png_zalloc
 ; png_zfree
 
+; Added at version 1.2.4
+  png_malloc_warn
+
 ; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS
   png_libpng_ver
   png_pass_start