Imported from libpng-1.0.6a.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index ec01b86..7582ece 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,85 +1,20 @@
 
-Libpng 1.0.6 - March 21, 2000
+Libpng 1.0.6a - April 2, 2000
 
-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.0.5):
+Changes since the last public release (1.0.6):
 
-  Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
-  Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
-  Further optimization and bugfix of pngvcrd.c
-  Revised pngset.c so that it does not allocate or free memory in the user's
-    text_ptr structure.  Instead, it makes its own copy.
-  Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak.
-  Created separate write_end_info_struct in pngtest.c for a more severe test.
-  Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and
-    PNG_FLAG_WROTE_tIME from flags to mode.
-  Added png_write_info_before_PLTE() function.
-  Fixed some typecasting in contrib/gregbook/*.c
-  Updated scripts/makevms.com (Martin Zinser)
-  Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr.
-  Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
-    accomodate making DLL's: Moved usr_png_ver from global variable to function
-    png_get_header_ver() in png.c.  Moved png_sig to png_sig_bytes in png.c and
-    eliminated use of png_sig in pngwutil.c.  Moved the various png_CHNK arrays
-    into local arrays.  Eliminated use of global png_pass arrays.  Declared the
-    png_CHNK and png_pass arrays to be "const".  Made the global arrays
-    available to applications when PNG_NO_GLOBAL_ARRAYS is not defined or
-    when PNG_USE_GLOBAL_ARRAYS is defined.  Made available to applications a
-    macro "PNG_USE_LOCAL_ARRAYS".
-  Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
-  Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
-  Added PNG_EXPORT_VAR macro to accommodate making DLL's.
-  Refactored the inflate/deflate support to make adding new chunks with
-    trailing compressed parts easier in the future (Eric S. Raymond).
-  Added iCCP, iTXt, sCAL, and sPLT support; added "lang", "lang_key", and
-    itxt_length" members to the png_text structure (Eric S. Raymond, Glenn R-P)
-  Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
-    offsets (Eric S. Raymond).
-  Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
-    PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
-    macros, leaving the separate macros also available.
-  Removed comments on #endifs at the end of many short, non-nested #if-blocks.
-  Changed makefile.solaris to issue a warning about potential problems when
-    the ucb "ld" is in the path ahead of the ccs "ld".
-  Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
-  Added code in pngwrite.c to work around a newly discovered zlib bug.
-  Unknown chunk handling is now supported (Eric S. Raymond).
-  Option to eliminate all floating point support was added.  Some new
-    fixed-point functions such as png_set_gAMA_fixed() were added.
-  Added new type "png_fixed_point" for integers that hold float*100000 values
-  Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
-  Added png_handle_as_unknown()
-  Added chunk_list and num_chunk_list members of png_ptr.
-  Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is.
-  Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr()
-    for setting a callback function to handle unknown chunks and for
-    retrieving the associated user pointer (Glenn).
-  Added png_free_data() function.
-  Added high-level functions png_read_png() and png_write_png() (ESR).
-  Renamed pngdll.mak to makefile.bd32
-  Cosmetic changes in pngtest.c
-  Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
-  Revised makefile.gcmmx
-  Fixed a bug in pngrtran.c that improperly expanded the background color.
-  Return *num_text=0 from png_get_text() when appropriate, and fix documentation
-    of png_get_text() in libpng.txt/libpng.3.
-  Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() and
-    "png_jmpbuf()" macros to pngconf.h, to help people migrate to the new error
-    handler that's planned for the next libpng release, and changed example.c,
-    pngtest.c, and contrib programs to use this macro.
-  Revised some of the DLL-export macros in pngconf.h (Greg Roelofs)
-  Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions
-    in pngget.c
-  Updated makefile.linux and makefile.gccmmx to make directories conditionally.
-  Increased precision of rgb_to_gray calculations from 8 to 15 bits and
-    added png_set_rgb_to_gray_fixed() function.
-  Added makefile.bc32 (32-bit Borland C++, C mode)
-  Updated references to the zlib home page, which has moved to freesoftware.com.
-  Corrected bugs in documentation regarding png_read_row() and png_write_row().
-  Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3,
-    revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin)
-  Added makefile.sggcc (SGI IRIX with gcc)
+version 1.0.6a [April 2, 2000]
+  Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO
+  Added data_length parameter to png_decompress_chunk() function
+  Revised documentation to remove reference to abandoned png_free_chnk functions
+  Fixed an error in png_rgb_to_gray_fixed()
+  Revised example.c, usage of png_destroy_write_struct().
+  Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
+  Added a check for info_ptr->free_me&PNG_FREE_TEXT when free'ing text in png.c
+  Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index faa1cac..a2f106c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -657,6 +657,20 @@
   Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt.
   Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3,
     revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin)
-version 1.0.6 [March 21, 2000]
+version 1.0.6 [March 20, 2000]
   Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c
   Added makefile.sggcc (SGI IRIX with gcc)
+version 1.0.6a [April 2, 2000]
+  Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO
+  Added data_length parameter to png_decompress_chunk() function
+  Revised documentation to remove reference to abandoned png_free_chnk functions
+  Fixed an error in png_rgb_to_gray_fixed()
+  Revised example.c, usage of png_destroy_write_struct().
+  Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
+  Added a check for info_ptr->free_me&PNG_FREE_TEXT when free'ing text in png.c
+  Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
+
+Send comments/corrections/commendations to
+png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
+
+Glenn R-P
diff --git a/INSTALL b/INSTALL
index ca69b87..0a512b4 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.0.6 - March 21, 2000
+Installing libpng version 1.0.6a - April 2, 2000
 
 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.0.6" or "lpng106" and "zlib-1.1.3"
+might be called "libpng-1.0.6a" or "lpng106" and "zlib-1.1.3"
 or "zlib113") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
@@ -47,8 +47,8 @@
 include
 
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
- makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6)
- makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6,
+ makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6a)
+ makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6a,
                        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
@@ -56,11 +56,12 @@
                        ftp://ftp.cs.wisc.edu/ghost)
  makefile.dec      =>  DEC Alpha UNIX makefile
  makefile.hpux     =>  HPUX (10.20 and 11.00) makefile
- makefile.ibmvac3  =>  IBM VisualAge/C++ version 3.x for Win32 and OS/2 (static)
+ makefile.ibmc     =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
+ libpng.icc        =>  Project file for IBM VisualAge/C++ version 4.0 or later
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
- makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng.so.2.1.0.6)
+ makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng.so.2.1.0.6a)
  makefile.sunos    =>  Sun makefile
- makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.6)
+ makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.6a)
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
  makefile.mips     =>  MIPS makefile
  makefile.acorn    =>  Acorn makefile
diff --git a/KNOWNBUG b/KNOWNBUG
index b15fecf..921d9aa 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -1,8 +1,47 @@
 
 Known bugs and suggested enhancements in libpng-1.0.6
 
+1. April 1, 2000 -- BUG
 
-1. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
+   Under some circumstances old applications that make direct access to
+   the info_ptr->text and its members might free the same memory that
+   is also free'ed by libpng during the png_destroy_struct process.
+
+   Fixed in libpng-1.0.6-patch-c and libpng-1.0.6a.  The PNG_FREE_TEXT flag
+   bit in info_ptr->free_me is now checked to make sure libpng is responsible
+   for freeing the memory.
+
+2. April 1, 2000 -- BUG
+
+   The non-ISO-C "strdup()" function is used in png.c
+
+   STATUS: The function has been simplified and no longer uses strdup()
+   in libpng-1.0.6-patch-c and libpng-1.0.6a.
+
+3. March 24, 2000 -- BUG
+
+   The png_set_rgb_to_gray_fixed() function is setting incorrect weighting
+   factors.
+
+   STATUS: Fixed in libpng-1.0.6-patch-b and libpng-1.0.6a.
+
+4. March 22, 2000 -- BUG
+
+   There are some printf() and fprintf() statements active in pngwutil.c
+   when PNG_NO_STDIO and PNG_sCAL_SUPPORTED are both defined.
+
+   STATUS: Fixed in libpng-1.0.6-patch-a and libpng-1.0.6a.  The strcpy()
+   function is used instead.
+
+5. March 22, 2000 -- BUG
+
+   The length of the iCCP chunk data is calculated incorrectly; because
+   it can contain zeroes, strlen() doesn't work.
+
+   STATUS: Fixed in libpng-1.0.6-patch-a by adding a data_length parameter
+   to the png_decompress_chunk() function.
+
+6. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
 
    Loops need to be optimized everywhere
 
@@ -17,7 +56,7 @@
    libpng-1.1.0.  About 160 loops will be turned around
    in libpng-1.1.Nn, for testing.
 
-2. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
+7. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
 
    libpng-1.0.5 and earlier transform colors to gamma=1.0 space for
    merging with background, and then back to the image's gamma.  The
@@ -29,7 +68,7 @@
 
    STATUS: under development.
 
-3. September 1999 -- ENHANCEMENT --
+8. September 1999 -- ENHANCEMENT --
 
    It should be possible to use libpng without floating-point aritmetic.
 
@@ -38,6 +77,6 @@
    for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
    functions will be needed.
 
-   Much of this was completed in libpng-1.0.5h, but gamma compensation
+   Much of this was completed in libpng-1.0.6, but gamma compensation
    is not yet done in fixed-point arithmetic.
 
diff --git a/LICENSE b/LICENSE
index 93e6d69..f74c206 100644
--- a/LICENSE
+++ b/LICENSE
@@ -5,7 +5,7 @@
 Copyright (c) 1996, 1997 Andreas Dilger
 (libpng versions 0.90, December 1996, through 0.96, May 1997)
 Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
-(libpng versions 0.97, January 1998, through 1.0.6, March 21, 2000)
+(libpng versions 0.97, January 1998, through 1.0.6a, April 2, 2000)
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
@@ -68,4 +68,4 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-March 21, 2000
+April 2, 2000
diff --git a/README b/README
index 55652af..1dac4f2 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.0.6 - March 21, 2000 (shared library 2.1)
+README for libpng 1.0.6a - April 2, 2000 (shared library 2.1)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -172,9 +172,9 @@
        descrip.mms      =>  VMS makefile for MMS or MMK
        makefile.std     =>  Generic UNIX makefile (cc, creates static libpng.a)
        makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng.so.2.1.0.6)
+                            (gcc, creates libpng.so.2.1.0.6a)
        makefile.gcmmx   =>  Linux/ELF makefile (gcc, creates
-                            libpng.so.2.1.0.6, uses assembler code
+                            libpng.so.2.1.0.6a, 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
@@ -182,12 +182,13 @@
                             ftp://ftp.cs.wisc.edu/ghost)
        makefile.dec     =>  DEC Alpha UNIX makefile
        makefile.hpux    =>  HPUX (10.20 and 11.00) makefile
-       makefile.ibmvac3 =>  IBM VisualAge/C++ ver 3.x for Win32, OS/2 (static)
+       makefile.ibmc    =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
+       libpng.icc       =>  Project file, IBM VisualAge/C++ 4.0 or later
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
-       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng.so.2.1.0.6)
+       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng.so.2.1.0.6a)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng.so.2.1.0.6)
+                            (gcc, creates libpng.so.2.1.0.6a)
        makefile.sco     =>  For SCO OSr5  ELF and Unixware 7 with Native cc
        makefile.mips    =>  MIPS makefile
        makefile.acorn   =>  Acorn makefile
diff --git a/Y2KINFO b/Y2KINFO
index 423e093..1a468e9 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      March 21, 2000
+      April 2, 2000
 
       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.0.6 are Y2K compliant.  It is my belief that earlier
+      upward through 1.0.6a 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 7ce18e1..61da8be 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 echo "
-  There is no \"configure\" script for Libpng-1.0.6.  Instead, please
+  There is no \"configure\" script for Libpng-1.0.6a.  Instead, please
   copy the appropriate makefile for your system from the \"scripts\"
   directory.  Read the INSTALL file for more details.
 "
diff --git a/example.c b/example.c
index ed2619c..3284b32 100644
--- a/example.c
+++ b/example.c
@@ -54,7 +54,7 @@
    char buf[PNG_BYTES_TO_CHECK];
 
    /* Open the prospective PNG file. */
-   if ((*fp = fopen(file_name, "rb")) != NULL);
+   if ((*fp = fopen(file_name, "rb")) == NULL)
       return 0;
 
    /* Read in some of the signature bytes */
@@ -565,7 +565,7 @@
    {
       /* If we get here, we had a problem reading the file */
       fclose(fp);
-      png_destroy_write_struct(&png_ptr,  (png_infopp)NULL);
+      png_destroy_write_struct(&png_ptr,  (png_infopp)info_ptr);
       return;
    }
 
@@ -761,7 +761,7 @@
    png_free(png_ptr, trans);
 
    /* clean up after the write, and free any memory allocated */
-   png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
+   png_destroy_write_struct(&png_ptr, (png_infopp)info_ptr);
 
    /* close the file */
    fclose(fp);
diff --git a/libpng.3 b/libpng.3
index 05b37a2..fd8ae51 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "March 21, 2000"
+.TH LIBPNG 3 "April 2, 2000"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6a
 .SH SYNOPSIS
 \fI\fB
 
@@ -713,7 +713,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.6 - March 21, 2000
+ libpng version 1.0.6a - April 2, 2000
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -1834,8 +1834,9 @@
                    (-1 for all items)
 
 These functions may be safely called when the relevant storage has
-already been freed, or has not yet been allocated, and will in that
-case do nothing.  The "n" parameter is ignored if only one item
+already been freed, or has not yet been allocated, or was allocated
+by the user and not by libpng,  and will in those
+cases do nothing.  The "n" parameter is ignored if only one item
 of the selected data type, such as PLTE, is allowed.  If "n" is not
 -1, and multiple items are allowed for the data type identified in
 the mask, such as text or splt, only the n'th item is freed.
@@ -2509,7 +2510,7 @@
 data.  For example, don't swap red and blue on grayscale data.
 
 PNG files store RGB pixels packed into 3 or 6 bytes.  This code tells
-the library to trip input data that has 4 or 8 bytes per pixel down
+the library to strip input data that has 4 or 8 bytes per pixel down
 to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
 bytes per pixel).
 
@@ -2712,30 +2713,24 @@
 It is also possible to individually free the info_ptr members that
 point to libpng-allocated storage with the following functions:
 
-    png_free_text(png_ptr, info_ptr, num)
-    num          - number of text item to be freed (-1 for all items)
-
-    png_free_hIST(png_ptr, info_ptr)
-
-    png_free_iCCP(png_ptr, info_ptr)
-
-    png_free_pCAL(png_ptr, info_ptr)
-
-    png_free_sCAL(png_ptr, info_ptr)
-
-    png_free_sPLT(png_ptr, info_ptr, num)
-    num          - number of suggested-paletted entry to be freed
-                   (-1 for all suggested palettes)
-
-    png_free_pixels(png_ptr, info_ptr)
-
-    png_free_unknown_chunk(png_ptr, info_ptr, num)
-    num          - number of unknown chunk entry to be freed
-                   (-1 for all suggested palettes)
+    png_free_data(png_ptr, info_ptr, mask, n)
+    mask         - identifies data to be freed, a mask
+                   made up by the OR one or more of
+                   PNG_FREE_PLTE, PNG_FREE_TRNS,
+                   PNG_FREE_HIST, PNG_FREE_ICCP,
+                   PNG_FREE_SPLT, PNG_FREE_ROWS,
+                   PNG_FREE_PCAL, PNG_FREE_SCAL,
+                   PNG_FREE_TEXT, PNG_FREE_UNKN,
+                   or simply PNG_FREE_ALL
+    n            - sequence number of item to be freed
+                   (-1 for all items)
 
 These functions may be safely called when the relevant storage has
 already been freed, or has not yet been allocated, and will in that
-case do nothing.
+case do nothing.  The "n" parameter is ignored if only one item
+of the selected data type, such as PLTE, is allowed.  If "n" is not
+-1, and multiple items are allowed for the data type identified in
+the mask, such as text or splt, only the n'th item is freed.
 
 If you allocated data such as a palette that you passed in to libpng with
 png_set_*, you must not free it until just before the call to
@@ -3113,13 +3108,13 @@
 
 .SH VII. Y2K Compliance in libpng
 
-March 21, 2000
+April 2, 2000
 
 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.0.6 are Y2K compliant.  It is my belief that earlier
+upward through 1.0.6a 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
@@ -3176,21 +3171,35 @@
 The following table summarizes matters since version 0.89c, which was
 the first widely used release:
 
-   source     png.h   png.h   shared-lib
-   version    string    int   version
-   -------    ------  ------  ----------
-   0.89c      0.89        89  1.0.89
-   0.90       0.90        90  0.90  [should be 2.0.90]
-   0.95       0.95        95  0.95  [should be 2.0.95]
-   0.96       0.96        96  0.96  [should be 2.0.96]
-   0.97b      1.00.97     97  1.0.1 [should be 2.0.97]
-   0.97c      0.97        97  2.0.97
-   0.98       0.98        98  2.0.98
-   0.99       0.99        98  2.0.99
-   0.99a-m    0.99        99  2.0.99
-   1.00       1.00       100  2.1.0 [int should be 10000]
-   1.0.0      1.0.0      100  2.1.0 [int should be 10000]
-   1.0.1      1.0.1    10001  2.1.0
+   source                   png.h    png.h   shared-lib
+   version                  string     int   version
+   -------                  ------   -----  ----------
+   0.89c ("1.0 beta 3")     0.89        89  1.0.89
+   0.90  ("1.0 beta 4")     0.90        90  0.90  [should have been 2.0.90]
+   0.95  ("1.0 beta 5")     0.95        95  0.95  [should have been 2.0.95]
+   0.96  ("1.0 beta 6")     0.96        96  0.96  [should have been 2.0.96]
+   0.97b ("1.00.97 beta 7") 1.00.97     97  1.0.1 [should have been 2.0.97]
+   0.97c                    0.97        97  2.0.97
+   0.98                     0.98        98  2.0.98
+   0.99                     0.99        98  2.0.99
+   0.99a-m                  0.99        99  2.0.99
+   1.00                     1.00       100  2.1.0 [100 should be 10000]
+   1.0.0                    1.0.0      100  2.1.0 [100 should be 10000]
+   1.0.1                    1.0.1    10001  2.1.0
+   1.0.1a-e                 1.0.1a-e 10002  2.1.0.1a-e
+   1.0.2                    1.0.2    10002  2.1.0.2
+   1.0.2a-b                 1.0.2a-b 10003  2.1.0.2a-b
+   1.0.3                    1.0.3    10003  2.1.0.3
+   1.0.3a-d                 1.0.3a-d 10004  2.1.0.3a-d
+   1.0.4                    1.0.4    10004  2.1.0.4
+   1.0.4a-f                 1.0.4a-f 10005  2.1.0.4a-f
+   1.0.5                    1.0.5    10005  2.1.0.5
+   1.0.5a-d                 1.0.5a-d 10006  2.1.0.5a-d
+   1.0.5e-r                 1.0.5e-r 10100  2.1.0.5e-r (not compatible)
+   1.0.5s-v                 1.0.5s-v 10006  2.1.0.5s-v (compatible)
+   1.0.6                    1.0.6    10006  2.1.0.6
+   1.0.6a                   1.0.6a   10007  2.1.0.6a
+   1.3.0                    1.3.0    10300  3.1.3.0
 
 Henceforth the source version will match the shared-library
 minor and patch numbers; the shared-library major version number will be
@@ -3245,7 +3254,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.0.6 - March 21, 2000:
+Libpng version 1.0.6a - April 2, 2000:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
 
@@ -3256,11 +3265,11 @@
 .SH COPYRIGHT NOTICE:
 
 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
-(libpng versions 0.5, May 1995, through 0.89c, May 1996)
+(libpng versions 0.5, May 1995, through 0.88, January 1996)
 Copyright (c) 1996, 1997 Andreas Dilger
-(libpng versions 0.90, December 1996, through 0.96, May 1997)
+(libpng versions 0.89c, May 1996, through 0.96, May 1997)
 Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
-(libpng versions 0.97, January 1998, through 1.0.6, March 21, 2000)
+(libpng versions 0.97, January 1998, through 1.0.6a, April 2, 2000)
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
diff --git a/libpng.txt b/libpng.txt
index b47e5d3..178e575 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.0.6 - March 21, 2000
+ libpng version 1.0.6a - April 2, 2000
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -1121,8 +1121,9 @@
                    (-1 for all items)
 
 These functions may be safely called when the relevant storage has
-already been freed, or has not yet been allocated, and will in that
-case do nothing.  The "n" parameter is ignored if only one item
+already been freed, or has not yet been allocated, or was allocated
+by the user and not by libpng,  and will in those
+cases do nothing.  The "n" parameter is ignored if only one item
 of the selected data type, such as PLTE, is allowed.  If "n" is not
 -1, and multiple items are allowed for the data type identified in
 the mask, such as text or splt, only the n'th item is freed.
@@ -1796,7 +1797,7 @@
 data.  For example, don't swap red and blue on grayscale data.
 
 PNG files store RGB pixels packed into 3 or 6 bytes.  This code tells
-the library to trip input data that has 4 or 8 bytes per pixel down
+the library to strip input data that has 4 or 8 bytes per pixel down
 to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
 bytes per pixel).
 
@@ -1999,30 +2000,24 @@
 It is also possible to individually free the info_ptr members that
 point to libpng-allocated storage with the following functions:
 
-    png_free_text(png_ptr, info_ptr, num)
-    num          - number of text item to be freed (-1 for all items)
-
-    png_free_hIST(png_ptr, info_ptr)
-
-    png_free_iCCP(png_ptr, info_ptr)
-
-    png_free_pCAL(png_ptr, info_ptr)
-
-    png_free_sCAL(png_ptr, info_ptr)
-
-    png_free_sPLT(png_ptr, info_ptr, num)
-    num          - number of suggested-paletted entry to be freed
-                   (-1 for all suggested palettes)
-
-    png_free_pixels(png_ptr, info_ptr)
-
-    png_free_unknown_chunk(png_ptr, info_ptr, num)
-    num          - number of unknown chunk entry to be freed
-                   (-1 for all suggested palettes)
+    png_free_data(png_ptr, info_ptr, mask, n)
+    mask         - identifies data to be freed, a mask
+                   made up by the OR one or more of
+                   PNG_FREE_PLTE, PNG_FREE_TRNS,
+                   PNG_FREE_HIST, PNG_FREE_ICCP,
+                   PNG_FREE_SPLT, PNG_FREE_ROWS,
+                   PNG_FREE_PCAL, PNG_FREE_SCAL,
+                   PNG_FREE_TEXT, PNG_FREE_UNKN,
+                   or simply PNG_FREE_ALL
+    n            - sequence number of item to be freed
+                   (-1 for all items)
 
 These functions may be safely called when the relevant storage has
 already been freed, or has not yet been allocated, and will in that
-case do nothing.
+case do nothing.  The "n" parameter is ignored if only one item
+of the selected data type, such as PLTE, is allowed.  If "n" is not
+-1, and multiple items are allowed for the data type identified in
+the mask, such as text or splt, only the n'th item is freed.
 
 If you allocated data such as a palette that you passed in to libpng with
 png_set_*, you must not free it until just before the call to
@@ -2400,13 +2395,13 @@
 
 VII. Y2K Compliance in libpng
 
-March 21, 2000
+April 2, 2000
 
 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.0.6 are Y2K compliant.  It is my belief that earlier
+upward through 1.0.6a 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 6a28361..2adc4e8 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 March 21, 2000
+.TH LIBPNGPF 3 April 2, 2000
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6a
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
@@ -55,6 +55,10 @@
 
 \fI\fB
 
+\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP
+
+\fI\fB
+
 \fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP
 
 \fI\fB
diff --git a/png.5 b/png.5
index 614b4a4..93b8723 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "March 21, 2000"
+.TH PNG 5 "April 2, 2000"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index 19130e6..35bb9ae 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.0.6 - March 21, 2000
+ * libpng version 1.0.6a - April 2, 2000
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -14,14 +14,14 @@
 #include "png.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_0_6 Your_png_h_is_not_version_1_0_6;
+typedef version_1_0_6a Your_png_h_is_not_version_1_0_6a;
 
 /* 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 */
-char png_libpng_ver[12] = "1.0.6";
+char png_libpng_ver[12] = "1.0.6a";
 
 /* png_sig was changed to a function in version 1.0.5c */
 /* Place to hold the signature string for a PNG file. */
@@ -269,7 +269,7 @@
 
 #if defined(PNG_TEXT_SUPPORTED)
 /* free text item num or (if num == -1) all text items */
-if (mask & PNG_FREE_TEXT)
+if (mask & PNG_FREE_TEXT & info_ptr->free_me & PNG_FREE_TEXT)
 {
    if (num != -1)
    {
@@ -535,17 +535,16 @@
 png_bytep
 png_sig_bytes(png_structp png_ptr)
 {
-   const png_byte png_sig_numbers[9] = {137, 80, 78, 71, 13, 10, 26, 10, 0};
-   if (png_ptr == NULL) /* silence compiler warning */
-     return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
-   return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
+   if (png_ptr != NULL || png_ptr == NULL)  /* silence compiler warning */
+     return ("\212\120\116\107\015\012\032\012");
+   return ("");
 }
 
 png_charp
 png_get_copyright(png_structp png_ptr)
 {
    if (png_ptr != NULL || png_ptr == NULL)  /* silence compiler warning */
-   return ("\n libpng version 1.0.6 - March 21, 2000\n\
+   return ("\n libpng version 1.0.6a - April 2, 2000\n\
    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
    Copyright (c) 1996, 1997 Andreas Dilger\n\
    Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n");
@@ -563,8 +562,8 @@
 {
    /* Version of *.c files used when building libpng */
    if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
-      return("1.0.6");
-   return("1.0.6");
+      return("1.0.6a");
+   return("1.0.6a");
 }
 
 png_charp
diff --git a/png.h b/png.h
index 5aaec69..ae3ac81 100644
--- a/png.h
+++ b/png.h
@@ -1,15 +1,15 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.0.6 - March 21, 2000
+ * libpng version 1.0.6a - April 2, 2000
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
  *
  * Authors and maintainers:
- *  libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
- *  libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
- *  libpng versions 0.97, January 1998, through 1.0.6 - March 21, 2000: Glenn
+ *  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.0.6a - April 2, 2000: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -45,8 +45,9 @@
  *    1.0.5                    1.0.5    10005  2.1.0.5
  *    1.0.5a-d                 1.0.5a-d 10006  2.1.0.5a-d
  *    1.0.5e-r                 1.0.5e-r 10100  2.1.0.5e-r (not compatible)
- *    1.0.5s-v                 1.0.5s-v 10006  2.1.0.5s-w (compatible)
+ *    1.0.5s-v                 1.0.5s-v 10006  2.1.0.5s-v (compatible)
  *    1.0.6                    1.0.6    10006  2.1.0.6
+ *    1.0.6a                   1.0.6a   10007  2.1.0.6a
  *    1.3.0                    1.3.0    10300  3.1.3.0
  *
  *    Henceforth the source version will match the shared-library minor
@@ -64,14 +65,16 @@
  */
 
 /*
- * COPYRIGHT NOTICE:
+ * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
+ *
+ * If you modify libpng you may insert additional notices after this sentence.
  *
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
- * (libpng versions 0.5, May 1995, through 0.89c, May 1996)
+ * (libpng versions 0.5, May 1995, through 0.88, January 1996)
  * Copyright (c) 1996, 1997 Andreas Dilger
- * (libpng versions 0.90, December 1996, through 0.96, May 1997)
+ * (libpng versions 0.89c, June 1996, through 0.96, May 1997)
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
- * (libpng versions 0.97, January 1998, through 1.0.6, March 21, 2000)
+ * (libpng versions 0.97, January 1998, through 1.0.6a, April 2, 2000)
  *
  * For the purposes of this copyright and license, "Contributing Authors"
  * is defined as the following set of individuals:
@@ -146,13 +149,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    March 21, 2000
+ *    April 2, 2000
  *
  *    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.0.6 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.0.6a 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
@@ -230,14 +233,14 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.0.6"
+#define PNG_LIBPNG_VER_STRING "1.0.6a"
 
 /* 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=bugfix */
-#define PNG_LIBPNG_VER    10006  /* 1.0.6 */
+#define PNG_LIBPNG_VER    10007  /* 1.0.7 */
 
 /* Note to maintainer: update this number in scripts/pngdef.pas as well */
 
@@ -651,13 +654,12 @@
 #ifdef PNG_FLOATING_POINT_SUPPORTED
    double scal_pixel_width;    /* width of one pixel */
    double scal_pixel_height;   /* height of one pixel */
-#else
+#endif
 #ifdef PNG_FIXED_POINT_SUPPORTED
    png_charp scal_s_width;     /* string containing height */
    png_charp scal_s_height;    /* string containing width */
 #endif
 #endif
-#endif
 
 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
    /* storage for unknown chunks that the library doesn't recognize. */
@@ -1056,9 +1058,9 @@
 };
 
 /* This prevents a compiler error in png_get_copyright() in png.c if png.c
-and png.h are both at * version 1.0.6
+and png.h are both at * version 1.0.6a
  */
-typedef png_structp version_1_0_6;
+typedef png_structp version_1_0_6a;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -2031,7 +2033,7 @@
 extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
 
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.0.6 - March 21, 2000 (header)\n"
+   " libpng version 1.0.6a - April 2, 2000 (header)\n"
 
 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
 /* With these routines we avoid an integer divide, which will be slower on
@@ -2304,7 +2306,7 @@
     defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_sPLT_SUPPORTED)
 PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr,
    int comp_type, png_charp chunkdata, png_size_t chunklength,
-   png_size_t prefix_size));
+   png_size_t prefix_length, png_size_t *data_length));
 #endif
 
 /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
@@ -2468,7 +2470,7 @@
 #endif
 
 #if defined(PNG_WRITE_sCAL_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
+#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
 PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
    int unit, double width, double height));
 #else
diff --git a/pngasmrd.h b/pngasmrd.h
index 87683db..1edc763 100644
--- a/pngasmrd.h
+++ b/pngasmrd.h
@@ -1,6 +1,6 @@
 /* pngasmrd.h - assembler version of utilities to read a PNG file
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1999, 2000 Glenn Randers-Pehrson
  *
diff --git a/pngconf.h b/pngconf.h
index 790c28a..0fc5952 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngerror.c b/pngerror.c
index cbfabc4..845ddb3 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pnggccrd.c b/pnggccrd.c
index 53b7cfb..f1608b7 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 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998, Intel Corporation
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
diff --git a/pngget.c b/pngget.c
index 36c97f1..0f0dd77 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngmem.c b/pngmem.c
index f7bb9de..a5960f9 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngpread.c b/pngpread.c
index 5264106..75b1ca5 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngread.c b/pngread.c
index de6497e..5915a67 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -641,7 +641,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.0.6.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6a.
  */
 
 void
@@ -690,7 +690,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.0.6.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6a.
  */
 void
 png_read_image(png_structp png_ptr, png_bytepp image)
diff --git a/pngrio.c b/pngrio.c
index e291780..a0afa59 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngrtran.c b/pngrtran.c
index bed4db7..02b1025 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -622,7 +622,7 @@
 #endif
    {
       png_uint_16 red_int, green_int;
-      if(red > 0 && green > 0)
+      if(red < 0 || green < 0)
       {
          red_int   =  6968; /* .212671 * 32768 + .5 */
          green_int = 23434; /* .715160 * 32768 + .5 */
diff --git a/pngrutil.c b/pngrutil.c
index fe22e6d..36d90ed 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -143,7 +143,7 @@
  */
 png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
                               png_charp chunkdata, png_size_t chunklength,
-                              png_size_t prefix_size)
+                              png_size_t prefix_size, png_size_t *newlength)
 {
    static char msg[] = "Error decoding compressed text";
    png_charp text = NULL;
@@ -227,6 +227,7 @@
 
       png_free(png_ptr, chunkdata);
       chunkdata = text;
+      *newlength=text_size;
    }
    else /* if (comp_type >= PNG_TEXT_COMPRESSION_LAST) */
    {
@@ -889,7 +890,7 @@
    png_byte compression_type;
    png_charp profile;
    png_uint_32 skip = 0;
-   png_size_t slength, prefix_length;
+   png_size_t slength, prefix_length, data_length;
 
    png_debug(1, "in png_handle_iCCP\n");
 
@@ -951,10 +952,10 @@
 
    prefix_length = profile - chunkdata;
    chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata,
-                                    slength, prefix_length);
+                                    slength, prefix_length, &data_length);
 
    png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type,
-                chunkdata + prefix_length, png_strlen(chunkdata + prefix_length));
+                chunkdata + prefix_length, data_length);
    png_free(png_ptr, chunkdata);
 }
 #endif /* PNG_READ_iCCP_SUPPORTED */
@@ -1722,7 +1723,7 @@
    png_charp chunkdata;
    png_charp text;
    int comp_type;
-   png_size_t slength, prefix_len;
+   png_size_t slength, prefix_len, data_len;
 
    png_debug(1, "in png_handle_zTXt\n");
    if (!(png_ptr->mode & PNG_HAVE_IHDR))
@@ -1770,7 +1771,7 @@
    prefix_len = text - chunkdata;
 
    chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata,
-                                    (png_size_t)length, prefix_len);
+                                    (png_size_t)length, prefix_len, &data_len);
 
    text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
    text_ptr->compression = comp_type;
@@ -1778,7 +1779,7 @@
    text_ptr->key = chunkdata;
    text_ptr->lang_key = NULL;
    text_ptr->text = chunkdata + prefix_len;
-   text_ptr->text_length = png_strlen(text);
+   text_ptr->text_length = data_len;
    text_ptr->itxt_length = 0;
 
    png_set_text(png_ptr, info_ptr, text_ptr, 1);
@@ -1798,7 +1799,7 @@
    png_charp key, lang, text, lang_key;
    int comp_flag;
    int comp_type = 0;
-   png_size_t slength, prefix_len;
+   png_size_t slength, prefix_len, data_len;
 
    png_debug(1, "in png_handle_iTXt\n");
 
@@ -1862,7 +1863,9 @@
    key=chunkdata;
    if (comp_flag)
        chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata,
-          (size_t)length, prefix_len);
+          (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->compression = (int)comp_flag + 1;
    text_ptr->lang_key = chunkdata+(lang_key-key);
@@ -1870,7 +1873,7 @@
    text_ptr->key = chunkdata;
    text_ptr->text = chunkdata + prefix_len;
    text_ptr->text_length = 0;
-   text_ptr->itxt_length = png_strlen(text_ptr->text);
+   text_ptr->itxt_length = data_len;
 
    png_set_text(png_ptr, info_ptr, text_ptr, 1);
 
diff --git a/pngset.c b/pngset.c
index f2f3462..fb88eb5 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngtest.c b/pngtest.c
index e2c3d12..eab586e 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -1344,4 +1344,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_0_6 your_png_h_is_not_version_1_0_6;
+typedef version_1_0_6a your_png_h_is_not_version_1_0_6a;
diff --git a/pngtrans.c b/pngtrans.c
index 7a5902d..0c4ce23 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.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngvcrd.c b/pngvcrd.c
index 5775fc0..4a46c13 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998, Intel Corporation
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
diff --git a/pngwio.c b/pngwio.c
index 19ebe35..6e98917 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwrite.c b/pngwrite.c
index a70038a..acc2a28 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -165,13 +165,16 @@
 #endif
 #if defined(PNG_WRITE_sCAL_SUPPORTED)
    if (info_ptr->valid & PNG_INFO_sCAL)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
+#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
       png_write_sCAL(png_ptr, (int)info_ptr->scal_unit,
           info_ptr->scal_pixel_width, info_ptr->scal_pixel_height);
 #else
 #ifdef PNG_FIXED_POINT_SUPPORTED
       png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
           info_ptr->scal_s_width, info_ptr->scal_s_height);
+#else
+      png_warning(png_ptr,
+          "png_write_sCAL not supported; sCAL chunk not written.\n");
 #endif
 #endif
 #endif
diff --git a/pngwtran.c b/pngwtran.c
index b4bea7e..1041077 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,7 +1,7 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwutil.c b/pngwutil.c
index 973b0ae..8affe2a 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.0.6 - March 21, 2000
+ * libpng 1.0.6a - April 2, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -795,7 +795,9 @@
        white_x + white_y > 1.0)
    {
       png_warning(png_ptr, "Invalid cHRM white point specified");
+#if !defined(PNG_NO_STDIO)
       printf("white_x=%f, white_y=%f\n",white_x, white_y);
+#endif
       return;
    }
    itemp = (png_uint_32)(white_x * 100000.0 + 0.5);
@@ -856,7 +858,9 @@
    if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L)
    {
       png_warning(png_ptr, "Invalid fixed cHRM white point specified");
+#if !defined(PNG_NO_STDIO)
       printf("white_x=%ld, white_y=%ld\n",white_x, white_y);
+#endif
       return;
    }
    png_save_uint_32(buf, white_x);
@@ -1381,7 +1385,7 @@
 
 #if defined(PNG_WRITE_sCAL_SUPPORTED)
 /* write the sCAL chunk */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
+#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
 void
 png_write_sCAL(png_structp png_ptr, int unit, double width,double height)
 {
@@ -1417,10 +1421,10 @@
    png_size_t total_len;
    char wbuf[32], hbuf[32];
 
-   png_debug(1, "in png_write_sCAL\n");
+   png_debug(1, "in png_write_sCAL_s\n");
 
-   sprintf(wbuf, "%s", width);
-   sprintf(hbuf, "%s", height);
+   strcpy(wbuf,(const char *)width);
+   strcpy(hbuf,(const char *)height);
    total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
 
    png_debug1(3, "sCAL total length = %d\n", total_len);
diff --git a/scripts/libpng.icc b/scripts/libpng.icc
new file mode 100644
index 0000000..e23b6b0
--- /dev/null
+++ b/scripts/libpng.icc
@@ -0,0 +1,43 @@
+// Project file for libpng (static)
+// IBM VisualAge/C++ version 4.0 or later
+// Copyright (C) 2000 Cosmin Truta
+// Notes:
+//   All modules are compiled in C mode
+//   Tested with IBM VAC++ 4.0 under Win32
+//   Expected to work with IBM VAC++ 4.0 or later under OS/2 and Win32
+//   Can be easily adapted for IBM VAC++ 4.0 or later under AIX
+// For conditions of distribution and use, see copyright notice in png.h
+
+option incl(searchpath, "../zlib"), opt(level, "2"),
+ link(libsearchpath, "../zlib")
+{
+   target type(lib) "libpng.lib"
+   {
+      source type(c) "png.c"
+      source type(c) "pngerror.c"
+      source type(c) "pngget.c"
+      source type(c) "pngmem.c"
+      source type(c) "pngpread.c"
+      source type(c) "pngread.c"
+      source type(c) "pngrio.c"
+      source type(c) "pngrtran.c"
+      source type(c) "pngrutil.c"
+      source type(c) "pngset.c"
+      source type(c) "pngtrans.c"
+      source type(c) "pngwio.c"
+      source type(c) "pngwrite.c"
+      source type(c) "pngwtran.c"
+      source type(c) "pngwutil.c"
+   }
+}
+
+option incl(searchpath, "../zlib"), opt(level, "2"),
+ link(libsearchpath, "../zlib")
+{
+   target type(exe) "pngtest.exe"
+   {
+      source type(c) "pngtest.c"
+      source type(lib) "libpng.lib"
+      source type(lib) "zlib.lib"
+   }
+}
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index 8731674..ef01492 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -31,7 +31,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6
+PNGMIN = 1.0.6a
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # where make install puts libpng.a, libpng.so*, and png.h
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index f8478a2..83f857a 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -14,7 +14,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6
+PNGMIN = 1.0.6a
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=cc
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index ea478d5..f6104a7 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -34,7 +34,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6
+PNGMIN = 1.0.6a
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.ibmvac3 b/scripts/makefile.ibmc
similarity index 90%
rename from scripts/makefile.ibmvac3
rename to scripts/makefile.ibmc
index a1cfa58..0de7d94 100644
--- a/scripts/makefile.ibmvac3
+++ b/scripts/makefile.ibmc
@@ -1,10 +1,10 @@
-# Makefile for libpng
-# IBM VisualAge/C++ version 3.x for Win32 and OS/2 (static)
+# Makefile for libpng (static)
+# IBM C version 3.x for Win32 and OS/2
 # Copyright (C) 2000 Cosmin Truta
 # Notes:
 #   Derived from makefile.std
 #   All modules are compiled in C mode
-#   Tested with VAC++ 3.6.5 under Win32, expected to work under OS/2 too
+#   Tested with IBM C 3.6.5 under Win32, expected to work under OS/2 too
 #   Can be easily adapted for IBM VisualAge/C++ for AIX
 # For conditions of distribution and use, see copyright notice in png.h
 
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 10dee5b..5a8aad7 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -34,7 +34,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6
+PNGMIN = 1.0.6a
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index 7a75715..5284b0a 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -25,7 +25,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6
+PNGMIN = 1.0.6a
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index 4c54631..408aa0c 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -19,8 +19,8 @@
 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
 LDSHARED=gcc -shared
 
-VER=1.0.6
-LIBS=libpng.so.1.0.6
+VER=1.0.6a
+LIBS=libpng.so.1.0.6a
 SHAREDLIB=libpng.so
 libdir=$(prefix)/lib32
 
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index 92d6f3e..9f5c06d 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -31,7 +31,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6
+PNGMIN = 1.0.6a
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index bfede12..bd7cb90 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -3,8 +3,8 @@
 interface
 
 const
-  PNG_LIBPNG_VER_STRING = '1.0.6';
-  PNG_LIBPNG_VER        =  10006;
+  PNG_LIBPNG_VER_STRING = '1.0.6a';
+  PNG_LIBPNG_VER        =  10007;
 
 type
   png_uint_32 = Cardinal;