Imported from libpng-1.0.11beta3.tar

This commit is contained in:
Glenn Randers-Pehrson 2001-04-14 20:15:41 -05:00
parent f64a06f5ec
commit e1eff58f87
53 changed files with 722 additions and 254 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.0.11beta2 - April 11, 2001
Libpng 1.0.11beta3 - April 15, 2001
This is a public release of libpng, intended for use in production codes.
@ -10,6 +10,7 @@ Changes since the last public release (1.0.10):
Changed several "//" single-line comments to C-style in pnggccrd.c
Removed PNGAPI from private functions whose prototypes did not have PNGAPI.
Updated scripts/pngos2.def
Added checking the results of many instances of png_malloc() for NULL
Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu

View File

@ -921,6 +921,8 @@ version 1.0.11beta1 [April 3, 2001]
version 1.0.11beta2 [April 11, 2001]
Removed PNGAPI from several functions whose prototypes did not have PNGAPI.
Updated scripts/pngos2.def
version 1.0.11beta3 [April 15, 2001]
Added checking the results of many instances of png_malloc() for NULL
Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu

12
INSTALL
View File

@ -1,5 +1,5 @@
Installing libpng version 1.0.11beta2 - April 11, 2001
Installing libpng version 1.0.11beta3 - April 15, 2001
Before installing libpng, you must first install zlib. zlib
can usually be found wherever you got libpng. zlib can be
@ -10,7 +10,7 @@ zlib.h and zconf.h include files that correspond to the
version of zlib that's installed.
You can rename the directories that you downloaded (they
might be called "libpng-1.0.11beta2" or "lpng109" and "zlib-1.1.3"
might be called "libpng-1.0.11beta3" 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:
@ -60,8 +60,8 @@ The files that are presently available in the scripts directory
include
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.11beta2)
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.11beta2,
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.11beta3)
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.11beta3,
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
@ -77,9 +77,9 @@ include
libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later
makefile.macosx => MACOS X Makefile
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.11beta2)
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.11beta3)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.11beta2)
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.11beta3)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile

View File

@ -21,3 +21,8 @@ Known bugs in libpng-1.0.10
involved are all either deprecated or intended only for internal use.
STATUS: PNGAPI was removed from the C code in libpng-1.0.11beta2.
4. April 14, 2001: Many instances of png_malloc() are not followed by
a check to make sure it didn't return NULL.
STATUS: tests were added in libpng-1.0.11beta3.

View File

@ -8,7 +8,7 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
libpng versions 1.0.7, July 1, 2000, through 1.0.11beta2, April 11, 2001, are
libpng versions 1.0.7, July 1, 2000, through 1.0.11beta3, April 15, 2001, are
Copyright (c) 2000, 2001 Glenn Randers-Pehrson
and are distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
@ -99,4 +99,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
randeg@alum.rpi.edu
April 11, 2001
April 15, 2001

10
README
View File

@ -1,4 +1,4 @@
README for libpng 1.0.11beta2 - April 11, 2001 (shared library 2.1)
README for libpng 1.0.11beta3 - April 15, 2001 (shared library 2.1)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@ -183,9 +183,9 @@ Files in this distribution:
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.11beta2)
(gcc, creates libpng.so.2.1.0.11beta3)
makefile.gcmmx => Linux/ELF makefile (gcc, creates
libpng.so.2.1.0.11beta2, uses assembler code
libpng.so.2.1.0.11beta3, 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
@ -201,10 +201,10 @@ Files in this distribution:
libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later
makefile.macosx => MACOS X Makefile
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.11beta2)
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.11beta3)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng.so.2.1.0.11beta2)
(gcc, creates libpng.so.2.1.0.11beta3)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile

View File

@ -1,13 +1,13 @@
Y2K compliance in libpng:
=========================
April 11, 2001
April 15, 2001
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.11beta2 are Y2K compliant. It is my belief that earlier
upward through 1.0.11beta3 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

2
configure vendored
View File

@ -1,5 +1,5 @@
echo "
There is no \"configure\" script for Libpng-1.0.11beta2. Instead, please
There is no \"configure\" script for Libpng-1.0.11beta3. Instead, please
copy the appropriate makefile for your system from the \"scripts\"
directory. Read the INSTALL file for more details.
"

View File

@ -603,7 +603,10 @@ void write_png(char *file_name /* , ... other image information ... */)
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * sizeof (png_color));
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
* sizeof (png_color));
if (palette == NULL)
png_error(png_ptr, "Example: malloc of palette failed");
/* ... set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
/* You must not free palette here, because png_set_PLTE only makes a link to

View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "April 11, 2001"
.TH LIBPNG 3 "April 15, 2001"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.11beta2
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.11beta3
.SH SYNOPSIS
\fI\fB
@ -747,7 +747,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng.txt - A description on how to use and modify libpng
libpng version 1.0.11beta2 - April 11, 2001
libpng version 1.0.11beta3 - April 15, 2001
Updated and distributed by Glenn Randers-Pehrson
<randeg@alum.rpi.edu>
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@ -3464,13 +3464,13 @@ application:
.SH VIII. Y2K Compliance in libpng
April 11, 2001
April 15, 2001
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.11beta2 are Y2K compliant. It is my belief that earlier
upward through 1.0.11beta3 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
@ -3579,7 +3579,7 @@ the first widely used release:
1.0.10beta1 1 10010 2.1.0.10beta1
1.0.10rc1 1 10010 2.1.0.10rc1
1.0.10 1 10010 2.1.0.10
1.0.11beta1-2 1 10011 2.1.0.11beta1-2
1.0.11beta1-3 1 10011 2.1.0.11beta1-3
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@ -3637,7 +3637,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.0.11beta2 - April 11, 2001:
Libpng version 1.0.11beta3 - April 15, 2001:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
@ -3654,7 +3654,7 @@ included in the libpng distribution, the latter shall prevail.)
If you modify libpng you may insert additional notices immediately following
this sentence.
libpng versions 1.0.7, July 1, 2000, through 1.0.11beta2, April 11, 2001, are
libpng versions 1.0.7, July 1, 2000, through 1.0.11beta3, April 15, 2001, are
Copyright (c) 2000-2001 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
@ -3746,7 +3746,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
randeg@alum.rpi.edu
April 11, 2001
April 15, 2001
.\" end of man page

View File

@ -1,6 +1,6 @@
libpng.txt - A description on how to use and modify libpng
libpng version 1.0.11beta2 - April 11, 2001
libpng version 1.0.11beta3 - April 15, 2001
Updated and distributed by Glenn Randers-Pehrson
<randeg@alum.rpi.edu>
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@ -2717,13 +2717,13 @@ application:
VIII. Y2K Compliance in libpng
April 11, 2001
April 15, 2001
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.11beta2 are Y2K compliant. It is my belief that earlier
upward through 1.0.11beta3 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

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "April 11, 2001"
.TH LIBPNGPF 3 "April 15, 2001"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.11beta2
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.11beta3
(private functions)
.SH SYNOPSIS
\fB#include <png.h>\fP

2
png.5
View File

@ -1,4 +1,4 @@
.TH PNG 5 "April 11, 2001"
.TH PNG 5 "April 15, 2001"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION

78
png.c
View File

@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
* libpng version 1.0.11beta2 - April 11, 2001
* libpng version 1.0.11beta3 - April 15, 2001
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -13,14 +13,14 @@
#include "png.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_0_11beta2 Your_png_h_is_not_version_1_0_11beta2;
typedef version_1_0_11beta3 Your_png_h_is_not_version_1_0_11beta3;
/* 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.0.11beta2";
const char png_libpng_ver[18] = "1.0.11beta3";
/* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */
@ -142,15 +142,18 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
#ifndef PNG_NO_ZALLOC_ZERO
if (num_bytes > (png_uint_32)0x8000L)
if (ptr)
{
png_memset(ptr, 0, (png_size_t)0x8000L);
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
(png_size_t)(num_bytes - (png_uint_32)0x8000L));
}
else
{
png_memset(ptr, 0, (png_size_t)num_bytes);
if (num_bytes > (png_uint_32)0x8000L)
{
png_memset(ptr, 0, (png_size_t)0x8000L);
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
(png_size_t)(num_bytes - (png_uint_32)0x8000L));
}
else
{
png_memset(ptr, 0, (png_size_t)num_bytes);
}
}
#endif
return ((voidpf)ptr);
@ -581,34 +584,39 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
sizeof(char)));
}
if (png_ptr->time_buffer == NULL)
png_warning(png_ptr, "Malloc of buffer for tIME chunk failed");
else
{
#if defined(_WIN32_WCE)
{
wchar_t time_buf[29];
wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29,
NULL, NULL);
}
{
wchar_t time_buf[29];
wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29,
NULL, NULL);
}
#else
#ifdef USE_FAR_KEYWORD
{
char near_time_buf[29];
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
png_memcpy(png_ptr->time_buffer, near_time_buf,
29*sizeof(char));
}
{
char near_time_buf[29];
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
png_memcpy(png_ptr->time_buffer, near_time_buf,
29*sizeof(char));
}
#else
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
#endif
#endif /* _WIN32_WCE */
}
return ((png_charp)png_ptr->time_buffer);
}
#endif /* PNG_TIME_RFC1123_SUPPORTED */
@ -626,7 +634,7 @@ png_charp PNGAPI
png_get_copyright(png_structp png_ptr)
{
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
return ((png_charp) "\n libpng version 1.0.11beta2 - April 11, 2001\n\
return ((png_charp) "\n libpng version 1.0.11beta3 - April 15, 2001\n\
Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n");
@ -644,8 +652,8 @@ png_get_libpng_ver(png_structp png_ptr)
{
/* Version of *.c files used when building libpng */
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return((png_charp) "1.0.11beta2");
return((png_charp) "1.0.11beta2");
return((png_charp) "1.0.11beta3");
return((png_charp) "1.0.11beta3");
}
png_charp PNGAPI

22
png.h
View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.0.11beta2 - April 11, 2001
* libpng version 1.0.11beta3 - April 15, 2001
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -9,7 +9,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.0.11beta2 - April 11, 2001: Glenn
* libpng versions 0.97, January 1998, through 1.0.11beta3 - April 15, 2001: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -67,7 +67,7 @@
* 1.0.10beta1 1 10010 2.1.0.10beta1
* 1.0.10rc1 1 10010 2.1.0.10rc1
* 1.0.10 1 10010 2.1.0.10
* 1.0.11beta1-2 1 10011 2.1.0.11beta1-2
* 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -97,7 +97,7 @@
* If you modify libpng you may insert additional notices immediately following
* this sentence.
*
* libpng versions 1.0.7, July 1, 2000, through 1.0.11beta2, April 11, 2001, are
* libpng versions 1.0.7, July 1, 2000, through 1.0.11beta3, April 15, 2001, are
* Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.0.6
* with the following individuals added to the list of Contributing Authors
@ -202,13 +202,13 @@
* Y2K compliance in libpng:
* =========================
*
* April 11, 2001
* April 15, 2001
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.0.11beta2 are Y2K compliant. It is my belief that earlier
* upward through 1.0.11beta3 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
@ -264,7 +264,7 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.0.11beta2"
#define PNG_LIBPNG_VER_STRING "1.0.11beta3"
#define PNG_LIBPNG_VER_SONUM 2
#define PNG_LIBPNG_VER_DLLNUM %DLLNUM%
@ -276,7 +276,7 @@
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
#define PNG_LIBPNG_VER_BUILD 2
#define PNG_LIBPNG_VER_BUILD 3
#define PNG_LIBPNG_BUILD_ALPHA 1
#define PNG_LIBPNG_BUILD_BETA 2
@ -1185,9 +1185,9 @@ struct png_struct_def
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
and png.h are both at * version 1.0.11beta2
and png.h are both at * version 1.0.11beta3
*/
typedef png_structp version_1_0_11beta2;
typedef png_structp version_1_0_11beta3;
typedef png_struct FAR * FAR * png_structpp;
@ -2235,7 +2235,7 @@ extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.0.11beta2 - April 11, 2001 (header)\n"
" libpng version 1.0.11beta3 - April 15, 2001 (header)\n"
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
/* With these routines we avoid an integer divide, which will be slower on

View File

@ -1,6 +1,6 @@
/* pngasmrd.h - assembler version of utilities to read a PNG file
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 2001 Glenn Randers-Pehrson
*

View File

@ -1,6 +1,6 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -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.0.11beta2 - April 11, 2001
* libpng version 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* Copyright (c) 1998, Intel Corporation

View File

@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -585,9 +585,18 @@ png_push_save_buffer(png_structp png_ptr)
old_buffer = png_ptr->save_buffer;
png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr,
(png_uint_32)new_max);
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
png_free(png_ptr, old_buffer);
png_ptr->save_buffer_max = new_max;
if (png_ptr->save_buffer == (png_bytep)NULL)
{
png_warning(png_ptr, "Malloc of save buffer failed");
png_ptr->save_buffer=old_buffer;
png_ptr->current_buffer_size = 0;
}
else
{
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
png_free(png_ptr, old_buffer);
png_ptr->save_buffer_max = new_max;
}
}
if (png_ptr->current_buffer_size)
{
@ -1017,6 +1026,12 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
(png_uint_32)(length+1));
if (png_ptr->current_text == (png_charp)NULL)
{
png_warning (png_ptr, "malloc of current text failed");
png_ptr->skip_length=length;
return;
}
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
@ -1068,6 +1083,11 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
text++;
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
if (text_ptr == (png_textp)NULL)
{
png_warning (png_ptr, "malloc of text buffer failed");
return;
}
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->key = key;
#ifdef PNG_iTXt_SUPPORTED
@ -1110,6 +1130,12 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
(png_uint_32)(length+1));
if (png_ptr->current_text == (png_charp)NULL)
{
png_warning (png_ptr, "malloc of zTXt buffer failed");
png_push_crc_skip(png_ptr, length);
return;
}
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
@ -1200,12 +1226,17 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
text = (png_charp)png_malloc(png_ptr,
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out +
key_size + 1));
png_memcpy(text + key_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
png_memcpy(text, key, key_size);
text_size = key_size + png_ptr->zbuf_size -
png_ptr->zstream.avail_out;
*(text + text_size) = '\0';
if (text == (png_charp)NULL)
png_warning(png_ptr, "Malloc of text block failed");
else
{
png_memcpy(text + key_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
png_memcpy(text, key, key_size);
text_size = key_size + png_ptr->zbuf_size -
png_ptr->zstream.avail_out;
*(text + text_size) = '\0';
}
}
else
{
@ -1215,12 +1246,17 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
text = (png_charp)png_malloc(png_ptr, text_size +
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
+ 1));
png_memcpy(text, tmp, text_size);
png_free(png_ptr, tmp);
png_memcpy(text + text_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
*(text + text_size) = '\0';
if (text != (png_charp)NULL)
png_warning(png_ptr, "Malloc of new text block failed");
else
{
png_memcpy(text, tmp, text_size);
png_free(png_ptr, tmp);
png_memcpy(text + text_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
*(text + text_size) = '\0';
}
}
if (ret != Z_STREAM_END)
{
@ -1252,18 +1288,23 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
text += key_size;
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr->key = key;
if (text_ptr == (png_textp)NULL)
png_warning (png_ptr, "Malloc of iTXt failed");
else
{
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr->key = key;
#ifdef PNG_iTXt_SUPPORTED
text_ptr->lang = (char *)NULL;
text_ptr->lang_key = (char *)NULL;
text_ptr->lang = (char *)NULL;
text_ptr->lang_key = (char *)NULL;
#endif
text_ptr->text = text;
text_ptr->text = text;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr);
}
png_free(png_ptr, key);
png_free(png_ptr, text_ptr);
}
}
#endif
@ -1292,11 +1333,16 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
(png_uint_32)(length+1));
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
png_ptr->current_text_left = (png_size_t)length;
png_ptr->process_mode = PNG_READ_iTXt_MODE;
if (png_ptr->current_text == (png_charp)NULL)
png_warning (png_ptr, "malloc of iTXt buffer failed");
else
{
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
png_ptr->current_text_left = (png_size_t)length;
png_ptr->process_mode = PNG_READ_iTXt_MODE;
}
}
void /* PRIVATE */
@ -1360,6 +1406,10 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
text++;
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
if(text_ptr == (png_textp)NULL)
png_warning (png_ptr, "Malloc of iTXt pointer failed");
else
{
text_ptr->compression = comp_flag + 2;
text_ptr->key = key;
text_ptr->lang = lang;
@ -1371,6 +1421,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr);
}
}
}
#endif
@ -1418,25 +1469,30 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, chunk.data, length);
chunk.size = length;
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
{
/* callback to user unknown chunk handler */
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
{
if (!(png_ptr->chunk_name[0] & 0x20))
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
HANDLE_CHUNK_ALWAYS)
png_chunk_error(png_ptr, "unknown critical chunk");
}
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
}
if (chunk.data == (png_bytep)NULL)
png_warning (png_ptr, "Malloc of unknown chunk data failed");
else
{
png_crc_read(png_ptr, chunk.data, length);
chunk.size = length;
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
{
/* callback to user unknown chunk handler */
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
{
if (!(png_ptr->chunk_name[0] & 0x20))
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
HANDLE_CHUNK_ALWAYS)
png_chunk_error(png_ptr, "unknown critical chunk");
}
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
}
else
#endif
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
png_free(png_ptr, chunk.data);
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
png_free(png_ptr, chunk.data);
}
}
else
#endif

View File

@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -115,6 +115,8 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
if (png_ptr->zbuf == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate zbuf");
png_ptr->zstream.zalloc = png_zalloc;
png_ptr->zstream.zfree = png_zfree;
png_ptr->zstream.opaque = (voidpf)png_ptr;
@ -197,6 +199,8 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
if (png_ptr->zbuf == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate zbuf");
png_ptr->zstream.zalloc = png_zalloc;
png_ptr->zstream.zfree = png_zfree;
png_ptr->zstream.opaque = (voidpf)png_ptr;
@ -715,7 +719,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
* 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.11beta2
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.11beta3
*/
void PNGAPI
@ -764,7 +768,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
* 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.11beta2
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.11beta3
*/
void PNGAPI
png_read_image(png_structp png_ptr, png_bytepp image)
@ -1305,7 +1309,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* Optional call to gamma correct and add the background to the palette
* and update info structure. REQUIRED if you are expecting libpng to
* update the palette for you (ie you selected such a transform above).
* update the palette for you (i.e., you selected such a transform above).
*/
png_read_update_info(png_ptr, info_ptr);
@ -1317,13 +1321,26 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
if(info_ptr->row_pointers == NULL)
{
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
info_ptr->height * sizeof(png_bytep));
info_ptr->height * sizeof(png_bytep));
if (info_ptr->row_pointers)
png_error(png_ptr, "png_read_png could not allocate row pointers");
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_ROWS;
#endif
for (row = 0; row < (int)info_ptr->height; row++)
{
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr));
if (info_ptr->row_pointers)
{
int allocated_row;
for (allocated_row=0; allocated_row < row; allocated_row++)
png_free(png_ptr, info_ptr->row_pointers[allocated_row]);
if (info_ptr->free_me & !(PNG_FREE_ROWS))
png_free (png_ptr, info_ptr->row_pointers);
png_error(png_ptr, "png_read_png could not allocate row pointer");
}
}
}
png_read_image(png_ptr, info_ptr->row_pointers);

View File

@ -1,7 +1,7 @@
/* pngrio.c - functions for data input
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -155,6 +155,11 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * sizeof (png_byte)));
if (png_ptr->dither_index == (png_bytep)NULL)
{
png_warning (png_ptr, "Malloc of dither index failed");
return;
}
for (i = 0; i < num_palette; i++)
png_ptr->dither_index[i] = (png_byte)i;
}
@ -172,6 +177,12 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
/* initialize an array to sort colors */
sort = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette
* sizeof (png_byte)));
if (sort == (png_bytep)NULL)
{
png_warning (png_ptr, "Malloc of sort array for dither failed");
png_free (png_ptr, png_ptr->dither_index);
return;
}
/* initialize the sort array */
for (i = 0; i < num_palette; i++)
@ -302,6 +313,14 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
(png_uint_32)(num_palette * sizeof (png_byte)));
palette_to_index = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * sizeof (png_byte)));
if (index_to_palette == (png_bytep)NULL || palette_to_index ==
(png_bytep)NULL)
{
png_warning (png_ptr, "Malloc of index array for dither failed");
png_free (png_ptr, index_to_palette);
png_free (png_ptr, png_ptr->dither_index);
return;
}
/* initialize the sort array */
for (i = 0; i < num_palette; i++)
@ -312,6 +331,14 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
sizeof (png_dsortp)));
if (hash == (png_dsortpp)NULL)
{
png_warning (png_ptr, "Malloc of hash array for dither failed");
png_free (png_ptr, palette_to_index);
png_free (png_ptr, index_to_palette);
png_free (png_ptr, png_ptr->dither_index);
return;
}
for (i = 0; i < 769; i++)
hash[i] = NULL;
/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */
@ -346,10 +373,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
t = (png_dsortp)png_malloc(png_ptr, (png_uint_32)(sizeof
(png_dsort)));
if (t != (png_dsortp)NULL)
{
t->next = hash[d];
t->left = (png_byte)i;
t->right = (png_byte)j;
hash[d] = t;
}
}
}
}
@ -456,16 +486,25 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
(png_uint_32)(num_entries * sizeof (png_byte)));
png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte));
if (png_ptr->palette_lookup == (png_bytep)NULL)
{
png_warning(png_ptr, "Malloc of palette_lookup for dither failed");
}
else
png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte));
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
sizeof(png_byte)));
png_memset(distance, 0xff, num_entries * sizeof(png_byte));
for (i = 0; i < num_palette; i++)
if (distance == (png_bytep)NULL)
{
png_warning(png_ptr, "Malloc of distance array for dither failed");
}
else
{
png_memset(distance, 0xff, num_entries * sizeof(png_byte));
for (i = 0; i < num_palette; i++)
{
int ir, ig, ib;
int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS));
int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS));
@ -496,11 +535,12 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
png_ptr->palette_lookup[d_index] = (png_byte)i;
}
}
}
}
}
}
}
}
png_free(png_ptr, distance);
}
}
}
#endif
@ -3858,6 +3898,11 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
if (png_ptr->gamma_table == (png_bytep)NULL)
{
png_warning (png_ptr, "Malloc of gamma table failed");
return;
}
for (i = 0; i < 256; i++)
{
@ -3874,6 +3919,11 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
if (png_ptr->gamma_to_1 == (png_bytep)NULL)
{
png_warning (png_ptr, "Malloc of gamma_to_1 table failed");
return;
}
for (i = 0; i < 256; i++)
{
@ -3884,6 +3934,11 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
if (png_ptr->gamma_from_1 == (png_bytep)NULL)
{
png_warning (png_ptr, "Malloc of gamma_from_1 table failed");
return;
}
if(png_ptr->screen_gamma > 0.000001)
g = 1.0 / png_ptr->screen_gamma;
@ -3946,6 +4001,11 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * sizeof (png_uint_16p)));
if (png_ptr->gamma_16_table == (png_uint_16pp)NULL)
{
png_warning (png_ptr, "Malloc of gamma_16 table failed");
return;
}
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
{
@ -3956,6 +4016,11 @@ png_build_gamma_table(png_structp png_ptr)
{
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * sizeof (png_uint_16)));
if (png_ptr->gamma_16_table[i] == (png_uint_16p)NULL)
{
png_warning (png_ptr, "Malloc of gamma_16 table entry failed");
return;
}
}
g = 1.0 / g;
@ -3986,6 +4051,11 @@ png_build_gamma_table(png_structp png_ptr)
{
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * sizeof (png_uint_16)));
if (png_ptr->gamma_16_table[i] == (png_uint_16p)NULL)
{
png_warning (png_ptr, "Malloc of gamma_16 table entry failed");
return;
}
ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
for (j = 0; j < 256; j++)
@ -4006,11 +4076,22 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * sizeof (png_uint_16p )));
if (png_ptr->gamma_16_to_1 == (png_uint_16pp)NULL)
{
png_warning (png_ptr, "Malloc of gamma_16_to_1 table failed");
return;
}
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * sizeof (png_uint_16)));
if (png_ptr->gamma_16_to_1[i] == (png_uint_16p)NULL)
{
png_warning (png_ptr,
"Malloc of gamma_16_to_1 table entry failed");
return;
}
ig = (((png_uint_32)i *
(png_uint_32)png_gamma_shift[shift]) >> 4);
@ -4029,11 +4110,23 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * sizeof (png_uint_16p)));
if (png_ptr->gamma_16_from_1 == (png_uint_16pp)NULL)
{
png_warning (png_ptr,
"Malloc of gamma_16_from_1 table failed");
return;
}
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * sizeof (png_uint_16)));
if (png_ptr->gamma_16_from_1[i] == (png_uint_16p)NULL)
{
png_warning (png_ptr,
"Malloc of gamma_16_from_1 table failed");
return;
}
ig = (((png_uint_32)i *
(png_uint_32)png_gamma_shift[shift]) >> 4);

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -201,15 +201,19 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
{
text_size = prefix_size + sizeof(msg) + 1;
text = (png_charp)png_malloc(png_ptr, text_size);
png_memcpy(text, chunkdata, prefix_size);
if (text != NULL)
png_memcpy(text, chunkdata, prefix_size);
}
text[text_size - 1] = 0x00;
if (text != NULL)
{
text[text_size - 1] = 0x00;
/* Copy what we can of the error message into the text chunk */
text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
png_memcpy(text + prefix_size, msg, text_size + 1);
/* Copy what we can of the error message into the text chunk */
text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
png_memcpy(text + prefix_size, msg, text_size + 1);
}
break;
}
if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END)
@ -219,10 +223,13 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
text_size = prefix_size +
png_ptr->zbuf_size - png_ptr->zstream.avail_out;
text = (png_charp)png_malloc(png_ptr, text_size + 1);
png_memcpy(text + prefix_size, png_ptr->zbuf,
if (text != NULL)
{
png_memcpy(text + prefix_size, png_ptr->zbuf,
text_size - prefix_size);
png_memcpy(text, chunkdata, prefix_size);
*(text + text_size) = 0x00;
png_memcpy(text, chunkdata, prefix_size);
*(text + text_size) = 0x00;
}
}
else
{
@ -231,12 +238,20 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
tmp = text;
text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size +
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
if (text != NULL)
{
png_memcpy(text, tmp, text_size);
png_free(png_ptr, tmp);
png_memcpy(text + text_size, png_ptr->zbuf,
(png_ptr->zbuf_size - png_ptr->zstream.avail_out));
text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
*(text + text_size) = 0x00;
}
else
{
png_warning (png_ptr, "Could not malloc text buffer");
text=tmp;
}
}
if (ret == Z_STREAM_END)
break;
@ -270,9 +285,13 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
if (text == NULL)
{
text = (png_charp)png_malloc(png_ptr, text_size+1);
png_memcpy(text, chunkdata, prefix_size);
if (text != NULL)
png_memcpy(text, chunkdata, prefix_size);
else
png_warning(png_ptr, "Could not malloc text chunkdata");
}
*(text + text_size) = 0x00;
if (text != NULL)
*(text + text_size) = 0x00;
}
inflateReset(&png_ptr->zstream);
@ -983,7 +1002,14 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
if (chunkdata != (png_charp)NULL)
png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
else
{
png_warning(png_ptr, "Could not allocate memory for iCCP chunk");
png_crc_finish(png_ptr, slength);
return;
}
if (png_crc_finish(png_ptr, skip))
{
@ -1079,8 +1105,16 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif
chunkdata = (png_bytep)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length;
png_crc_read(png_ptr, chunkdata, slength);
if (chunkdata != (png_bytep)NULL)
{
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
}
else
{
png_warning(png_ptr, "Could not allocate memory for sPLT chunk");
skip = (png_size_t)length;
}
if (png_crc_finish(png_ptr, skip))
{
@ -1110,12 +1144,19 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (data_length % entry_size)
{
png_free(png_ptr, chunkdata);
png_error(png_ptr, "sPLT chunk has bad length");
png_warning(png_ptr, "sPLT chunk has bad length");
return;
}
new_palette.nentries = data_length / entry_size;
new_palette.entries = (png_sPLT_entryp)png_malloc(
png_ptr, new_palette.nentries * sizeof(png_sPLT_entry));
if (new_palette.entries == (png_sPLT_entryp)NULL)
{
png_free(png_ptr, chunkdata);
png_warning (png_ptr, "Could not allocate sPLT entries");
return;
}
#ifndef PNG_NO_POINTER_INDEXING
for (i = 0; i < new_palette.nentries; i++)
@ -1525,6 +1566,12 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n",
length + 1);
purpose = (png_charp)png_malloc(png_ptr, length + 1);
if (purpose == (png_charp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for pCAL purpose");
png_crc_finish(png_ptr, length);
return;
}
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)purpose, slength);
@ -1581,6 +1628,11 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_debug(3, "Allocating pCAL parameters array\n");
params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams
*sizeof(png_charp))) ;
if (params == (png_charpp)NULL)
{
png_warning (png_ptr, "Could not allocate pCAL parameters array");
nparams=0;
}
/* Get pointers to the start of each parameter string. */
for (i = 0; i < (int)nparams; i++)
@ -1645,6 +1697,12 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n",
length + 1);
buffer = (png_charp)png_malloc(png_ptr, length + 1);
if (buffer == (png_charp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for sCAL buffer");
png_crc_finish(png_ptr, length);
return;
}
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)buffer, slength);
@ -1668,7 +1726,8 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
swidth = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1);
png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
if (swidth != (png_charp)NULL)
png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
#endif
#endif
@ -1686,7 +1745,8 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
sheight = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1);
png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
if (sheight != (png_charp)NULL)
png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
#endif
#endif
@ -1795,7 +1855,14 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
key = (png_charp)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)key, slength);
if (key == (png_charp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for tEXt chunk");
png_crc_finish(png_ptr, slength);
return;
}
else
png_crc_read(png_ptr, (png_bytep)key, slength);
if (png_crc_finish(png_ptr, skip))
{
@ -1812,6 +1879,8 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text++;
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
if (text_ptr != (png_textp)NULL)
{
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->key = key;
#ifdef PNG_iTXt_SUPPORTED
@ -1824,8 +1893,11 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, key);
png_free(png_ptr, text_ptr);
}
else
png_warning(png_ptr, "Could not allocate iTXt pointer");
png_free(png_ptr, key);
}
#endif
@ -1859,8 +1931,17 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif
chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
if (chunkdata != (png_charp)NULL)
{
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
}
else
{
png_warning (png_ptr, "Could not allocate memory for zTXt chunk data");
png_crc_finish(png_ptr, length);
return;
}
if (png_crc_finish(png_ptr, 0))
{
png_free(png_ptr, chunkdata);
@ -1894,19 +1975,24 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
(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;
text_ptr->key = chunkdata;
if (text_ptr != (png_textp)NULL)
{
text_ptr->compression = comp_type;
text_ptr->key = chunkdata;
#ifdef PNG_iTXt_SUPPORTED
text_ptr->lang = NULL;
text_ptr->lang_key = NULL;
text_ptr->itxt_length = 0;
text_ptr->lang = NULL;
text_ptr->lang_key = NULL;
text_ptr->itxt_length = 0;
#endif
text_ptr->text = chunkdata + prefix_len;
text_ptr->text_length = data_len;
text_ptr->text = chunkdata + prefix_len;
text_ptr->text_length = data_len;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr);
png_free(png_ptr, text_ptr);
}
else
png_warning (png_ptr, "Could not allocate memory for zTXt data");
png_free(png_ptr, chunkdata);
}
#endif
@ -1943,8 +2029,17 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif
chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
if (chunkdata != (png_charp)NULL)
{
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
}
else
{
png_warning (png_ptr, "Could not allocate memory for iTXt chunk data");
png_crc_finish(png_ptr, length);
return;
}
if (png_crc_finish(png_ptr, 0))
{
png_free(png_ptr, chunkdata);
@ -1989,17 +2084,22 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
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);
text_ptr->lang = chunkdata+(lang-key);
text_ptr->itxt_length = data_len;
text_ptr->text_length = 0;
text_ptr->key = chunkdata;
text_ptr->text = chunkdata + prefix_len;
if (text_ptr != (png_textp)NULL)
{
text_ptr->compression = (int)comp_flag + 1;
text_ptr->lang_key = chunkdata+(lang_key-key);
text_ptr->lang = chunkdata+(lang-key);
text_ptr->itxt_length = data_len;
text_ptr->text_length = 0;
text_ptr->key = chunkdata;
text_ptr->text = chunkdata + prefix_len;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr);
png_free(png_ptr, text_ptr);
}
else
png_warning (png_ptr, "Could not allocate memory for iTXt chunk data");
png_free(png_ptr, chunkdata);
}
#endif
@ -2055,8 +2155,17 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif
png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, chunk.data, length);
chunk.size = length;
if (chunk.data != (png_bytep)NULL)
{
chunk.size = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunk.data, length);
}
else
{
png_warning (png_ptr, "Could not allocate memory for iTXt chunk data");
png_crc_finish(png_ptr, length);
return;
}
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
{
@ -2963,6 +3072,8 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_error(png_ptr, "This image requires a row greater than 64KB");
#endif
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes);
if (png_ptr->row_buf == (png_bytep)NULL)
png_error (png_ptr, "Could not allocate memory for row buffer");
png_ptr->row_buf_size = row_bytes;
#ifdef PNG_MAX_MALLOC_64K
@ -2971,6 +3082,11 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
#endif
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
png_ptr->rowbytes + 1));
if (png_ptr->prev_row == (png_bytep)NULL)
{
png_free (png_ptr, png_ptr->row_buf);
png_error (png_ptr, "Could not allocate memory for previous row buffer");
}
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);

128
pngset.c
View File

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -143,14 +143,22 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->num_palette == 0)
{
png_warning(png_ptr,
"Palette size 0, hIST allocation skipped.");
"Palette size 0, hIST allocation skipped.");
return;
}
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
#endif
png_ptr->hist = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(info_ptr->num_palette * sizeof (png_uint_16)));
if (png_ptr->hist == (png_uint_16p)NULL)
{
png_warning (png_ptr, "Could not allocate memory for histogram");
return;
}
for (i = 0; i < info_ptr->num_palette; i++)
png_ptr->hist[i] = hist[i];
@ -292,6 +300,11 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
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);
if (info_ptr->pcal_purpose == (png_charp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for pCAL");
return;
}
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
png_debug(3, "storing X0, X1, type, and nparams in info\n");
@ -303,10 +316,24 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
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);
if (info_ptr->pcal_units == (png_charp)NULL)
{
png_free (png_ptr, info_ptr->pcal_purpose);
png_warning (png_ptr, "Could not allocate 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,
(png_uint_32)((nparams + 1) * sizeof(png_charp)));
if (info_ptr->pcal_params == (png_charpp)NULL)
{
png_free (png_ptr, info_ptr->pcal_purpose);
png_free (png_ptr, info_ptr->pcal_units);
png_warning (png_ptr, "Could not allocate memory for pCAL params");
return;
}
info_ptr->pcal_params[nparams] = NULL;
for (i = 0; i < nparams; i++)
@ -314,7 +341,13 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
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);
png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
if (info_ptr->pcal_params[i] == (png_charp)NULL)
{
nparams=i;
png_warning (png_ptr, "Could not allocate memory for pCAL params");
}
else
png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
}
info_ptr->valid |= PNG_INFO_pCAL;
@ -357,12 +390,14 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(swidth) + 1;
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length);
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
if (info_ptr->scal_s_width != (png_charp)NULL)
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
length = png_strlen(sheight) + 1;
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length);
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length);
if (info_ptr->scal_s_height != (png_charp)NULL)
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
info_ptr->valid |= PNG_INFO_sCAL;
#ifdef PNG_FREE_ME_SUPPORTED
@ -408,6 +443,11 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
#endif
png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)num_palette,
sizeof (png_color));
if (png_ptr->palette == (png_colorp)NULL)
{
png_warning(png_ptr, "Unable to allocate palette");
return;
}
png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color));
info_ptr->palette = png_ptr->palette;
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
@ -532,8 +572,19 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
return;
new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1);
if (new_iccp_name == (png_charp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for ICC profile name");
return;
}
png_strcpy(new_iccp_name, name);
new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen);
if (new_iccp_profile == (png_charp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for ICC profile");
png_free (png_ptr, new_iccp_name);
return;
}
png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
@ -579,6 +630,12 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
old_text = info_ptr->text;
info_ptr->text = (png_textp)png_malloc(png_ptr,
(png_uint_32)(info_ptr->max_text * sizeof (png_text)));
if (info_ptr->text == (png_textp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for text");
info_ptr->text = old_text;
return;
}
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
sizeof(png_text)));
png_free(png_ptr, old_text);
@ -589,6 +646,11 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
info_ptr->num_text = 0;
info_ptr->text = (png_textp)png_malloc(png_ptr,
(png_uint_32)(info_ptr->max_text * sizeof (png_text)));
if (info_ptr->text == (png_textp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for text");
return;
}
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TEXT;
#endif
@ -650,6 +712,11 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
textp->key = (png_charp)png_malloc(png_ptr,
(png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
if (textp->key == (png_charp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for text pointer");
return;
}
png_debug2(2, "Allocated %d bytes at %x in png_set_text\n",
key_len + lang_len + lang_key_len + text_length + 4, (int)textp->key);
@ -737,6 +804,11 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
#endif
png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
num_trans);
if (png_ptr->trans == (png_bytep)NULL)
{
png_warning (png_ptr, "Could not allocate memory for tRNS array");
return;
}
png_memcpy(info_ptr->trans, trans, num_trans);
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TRNS;
@ -767,6 +839,11 @@ png_set_sPLT(png_structp png_ptr,
np = (png_sPLT_tp)png_malloc(png_ptr,
(info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t));
if (np == (png_sPLT_tp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for sPLT");
return;
}
png_memcpy(np, info_ptr->splt_palettes,
info_ptr->splt_palettes_num * sizeof(png_sPLT_t));
@ -779,14 +856,22 @@ png_set_sPLT(png_structp png_ptr,
png_sPLT_tp from = entries + i;
to->name = (png_charp)png_malloc(png_ptr,
png_strlen(from->name) + 1);
png_strlen(from->name) + 1);
png_strcpy(to->name, from->name);
to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
from->nentries * sizeof(png_sPLT_t));
png_memcpy(to->entries, from->entries,
from->nentries * sizeof(png_sPLT_t));
if (to->entries == (png_sPLT_entryp)NULL)
{
png_warning(png_ptr, "Could not allocate memory for sPLT entry");
nentries=i;
}
else
{
png_memcpy(to->entries, from->entries,
from->nentries * sizeof(png_sPLT_t));
to->nentries = from->nentries;
to->depth = from->depth;
to->nentries = from->nentries;
to->depth = from->depth;
}
}
info_ptr->splt_palettes = np;
@ -812,6 +897,11 @@ png_set_unknown_chunks(png_structp png_ptr,
np = (png_unknown_chunkp)png_malloc(png_ptr,
(info_ptr->unknown_chunks_num + num_unknowns) *
sizeof(png_unknown_chunk));
if (np == (png_unknown_chunkp)NULL)
{
png_warning (png_ptr, "Could not allocate memory for unknown chunk");
return;
}
png_memcpy(np, info_ptr->unknown_chunks,
info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk));
@ -825,11 +915,19 @@ png_set_unknown_chunks(png_structp png_ptr,
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 == (png_bytep)NULL)
{
png_warning(png_ptr, "Could not allocate memory for unknown entry");
num_unknowns=i;
}
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;

View File

@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -1523,4 +1523,4 @@ main(int argc, char *argv[])
}
/* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_0_11beta2 your_png_h_is_not_version_1_0_11beta2;
typedef version_1_0_11beta3 your_png_h_is_not_version_1_0_11beta3;

View File

@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -2,7 +2,7 @@
*
* For Intel x86 CPU and Microsoft Visual C++ compiler
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* Copyright (c) 1998, Intel Corporation

View File

@ -1,7 +1,7 @@
/* pngwio.c - functions for data output
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -512,6 +512,8 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
if (png_ptr->zbuf == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate zbuf for writing");
png_set_write_fn(png_ptr, NULL, NULL, NULL);
@ -581,6 +583,8 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
if (png_ptr->zbuf == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate zbuf for writing");
png_set_write_fn(png_ptr, NULL, NULL, NULL);
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
@ -1029,6 +1033,8 @@ png_set_filter(png_structp png_ptr, int method, int filters)
{
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
if (png_ptr->sub_row == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate sub_row");
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
}
@ -1043,6 +1049,10 @@ png_set_filter(png_structp png_ptr, int method, int filters)
{
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
if (png_ptr->up_row == (png_bytep)NULL)
{
png_error(png_ptr, "Could not allocate sub_row");
}
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
}
@ -1058,6 +1068,8 @@ png_set_filter(png_structp png_ptr, int method, int filters)
{
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
if (png_ptr->avg_row == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate avg_row");
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
}
}
@ -1074,6 +1086,8 @@ png_set_filter(png_structp png_ptr, int method, int filters)
{
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
if (png_ptr->paeth_row == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate avg_row");
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
}
@ -1129,10 +1143,13 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(sizeof(png_byte) * num_weights));
/* To make sure that the weighting starts out fairly */
for (i = 0; i < num_weights; i++)
if (png_ptr->prev_filters != (png_bytep)NULL)
{
png_ptr->prev_filters[i] = 255;
/* To make sure that the weighting starts out fairly */
for (i = 0; i < num_weights; i++)
{
png_ptr->prev_filters[i] = 255;
}
}
}
@ -1143,12 +1160,22 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(sizeof(png_uint_16) * num_weights));
for (i = 0; i < num_weights; i++)
if (png_ptr->inv_filter_weights == (png_uint_16p)NULL)
{
png_ptr->inv_filter_weights[i] =
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
png_free(png_ptr, png_ptr->filter_weights);
png_ptr->filter_weights = NULL;
}
if (png_ptr->filter_weights != (png_uint_16p)NULL &&
png_ptr->inv_filter_weights != (png_uint_16p)NULL)
{
for (i = 0; i < num_weights; i++)
{
png_ptr->inv_filter_weights[i] =
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
}
}
else
num_weights=0;
}
for (i = 0; i < num_weights; i++)

View File

@ -1,7 +1,7 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
* libpng 1.0.11beta2 - April 11, 2001
* libpng 1.0.11beta3 - April 15, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -235,21 +235,35 @@ png_text_compress(png_structp png_ptr,
old_ptr = comp->output_ptr;
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
png_memcpy(comp->output_ptr, old_ptr,
old_max * sizeof (png_charp));
if (comp->output_ptr == (png_charpp)NULL)
{
png_warning (png_ptr, "Cannot allocate compression buffer");
comp->output_ptr=old_ptr;
}
png_memcpy(comp->output_ptr, old_ptr, old_max
* sizeof (png_charp));
png_free(png_ptr, old_ptr);
}
else
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charp)));
if (comp->output_ptr == (png_charpp)NULL)
{
png_warning (png_ptr, "Cannot allocate compression buffer");
}
}
/* save the data */
comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);
comp->num_output_ptr++;
if (comp->output_ptr[comp->num_output_ptr] == (png_charp)NULL)
png_warning (png_ptr, "Cannot allocate compression buffer");
else
{
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);
comp->num_output_ptr++;
}
/* and reset the buffer */
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
@ -284,8 +298,9 @@ png_text_compress(png_structp png_ptr,
/* This could be optimized to realloc() */
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
png_memcpy(comp->output_ptr, old_ptr,
old_max * sizeof (png_charp));
if (comp->output_ptr != (png_charpp)NULL)
png_memcpy(comp->output_ptr, old_ptr,
old_max * sizeof (png_charp));
png_free(png_ptr, old_ptr);
}
else
@ -296,9 +311,14 @@ png_text_compress(png_structp png_ptr,
/* save off the data */
comp->output_ptr[comp->num_output_ptr] =
(png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size);
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);
comp->num_output_ptr++;
if (comp->output_ptr[comp->num_output_ptr] == (png_charp)NULL)
png_warning (png_ptr, "Cannot allocate compression buffer");
else
{
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);
comp->num_output_ptr++;
}
/* and reset the buffer pointers */
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
@ -1110,6 +1130,12 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
*new_key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + 2));
if (*new_key == (png_charp)NULL)
{
png_warning(png_ptr, "Could not allocate new key; keyword not checked");
return key_len;
}
/* Replace non-printing characters with a blank and print a warning */
for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
{
@ -1425,6 +1451,12 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams
*sizeof(png_uint_32)));
if (params_len == (png_uint_32p)NULL)
{
png_warning (png_ptr, "Could not allocate params for pCAL");
return;
}
/* Find the length of each parameter, making sure we don't count the
null terminator for the last parameter. */
for (i = 0; i < nparams; i++)
@ -1608,6 +1640,8 @@ png_write_start_row(png_structp png_ptr)
/* set up row buffer */
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
if (png_ptr->row_buf == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate row buffer");
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
/* set up filtering buffer, if using this filter */
@ -1615,6 +1649,8 @@ png_write_start_row(png_structp png_ptr)
{
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
if (png_ptr->sub_row == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate sub row buffer");
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
}
@ -1629,6 +1665,8 @@ png_write_start_row(png_structp png_ptr)
{
png_ptr->up_row = (png_bytep )png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
if (png_ptr->up_row == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate up row buffer");
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
@ -1636,6 +1674,8 @@ png_write_start_row(png_structp png_ptr)
{
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
if (png_ptr->avg_row == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate avg row buffer");
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
}
@ -1643,6 +1683,8 @@ png_write_start_row(png_structp png_ptr)
{
png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
if (png_ptr->paeth_row == (png_bytep)NULL)
png_error(png_ptr, "Could not allocate paeth row buffer");
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
}

View File

@ -1,5 +1,5 @@
Microsoft Developer Studio Build File, Format Version 6.00 for
libpng 1.0.11beta2 (April 11, 2001) and zlib
libpng 1.0.11beta3 (April 15, 2001) and zlib
Copyright (C) 2000 Simon-Pierre Cadieux
For conditions of distribution and use, see copyright notice in png.h

View File

@ -6,7 +6,7 @@ LIBRARY
DESCRIPTION "PNG image compression library for Windows"
EXPORTS
;Version 1.0.11beta2
;Version 1.0.11beta3
png_build_grayscale_palette @1
png_check_sig @2
png_chunk_error @3

View File

@ -8,9 +8,9 @@ libpng for WindowsCE Rel.1.0
Introduction
============
This is libpng 1.0.11beta2 ported to WindowsCE 2.0 and 2.11.
libpng 1.0.11beta2 is a PNG reference library.
See README, a document of original libpng 1.0.11beta2.
This is libpng 1.0.11beta3 ported to WindowsCE 2.0 and 2.11.
libpng 1.0.11beta3 is a PNG reference library.
See README, a document of original libpng 1.0.11beta3.
zlib for WindowsCE
==================
@ -23,7 +23,7 @@ This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
See README and LICENSE, documents of original libpng 1.0.11beta2, for conditions
See README and LICENSE, documents of original libpng 1.0.11beta3, for conditions
of use and distribution.
Files

View File

@ -24,7 +24,7 @@ libpng
になったいかなる被害についても、作者、配布者、その他利用者以外の人物、
団体に責任をとる義務はないものとします。
その他、このソフトウェアの利用条件については、原版である libpng 1.0.11beta2
その他、このソフトウェアの利用条件については、原版である libpng 1.0.11beta3
準拠するものとします。詳しくは、付属の README,LICENSE をお読みください。
収録内容

View File

@ -5,7 +5,7 @@
LIBRARY lpngce
EXPORTS
;Version 1.0.11beta2
;Version 1.0.11beta3
png_build_grayscale_palette @1
png_check_sig @2
png_chunk_error @3

View File

@ -18,7 +18,7 @@ RM = rm -f
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
prefix=/usr/local

View File

@ -13,7 +13,7 @@ ZLIBINC=/usr/local/include
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
ALIGN=

View File

@ -39,8 +39,8 @@ CFLAGS=-I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \
# have to change it.
PNGMAJ = 2
#PNGDLL = $1# msvc
PNGDLL = 2# cygwin 1.0.11beta2
PNGMIN = 1.0.11beta2
PNGDLL = 2# cygwin 1.0.11beta3
PNGMIN = 1.0.11beta3
PNGMIN_BASE = 1.0.11
PNGVER = $(PNGMAJ).$(PNGMIN)

View File

@ -17,7 +17,7 @@ ZLIBINC=../zlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
CC=cc

View File

@ -51,7 +51,7 @@ RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include

View File

@ -34,7 +34,7 @@ RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include

View File

@ -19,7 +19,7 @@ RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a and png.h

View File

@ -34,7 +34,7 @@ RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include

View File

@ -25,7 +25,7 @@ RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include

View File

@ -19,8 +19,8 @@ CFLAGS=-I$(ZLIBINC) -O2 $(WARNMORE) -fPIC -mabi=n32
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
LDSHARED=gcc -shared
VER=1.0.11beta2
LIBS=libpng.so.1.0.11beta2
VER=1.0.11beta3
LIBS=libpng.so.1.0.11beta3
SHAREDLIB=libpng.so
libdir=$(prefix)/lib32

View File

@ -25,7 +25,7 @@ CFLAGS=-I$(ZLIBINC) -O $(WARNMORE) -DPNG_USE_PNGGCCRD -DPNG_NO_ASSEMBLER_CODE
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
LDSHARED=cc -shared
VER=1.0.11beta2
VER=1.0.11beta3
SONUM=2
SHAREDLIB=libpng.so
libdir=$(prefix)

View File

@ -31,7 +31,7 @@ RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.11beta2
PNGMIN = 1.0.11beta3
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include

View File

@ -7,7 +7,7 @@ unit pngdef;
interface
const
PNG_LIBPNG_VER_STRING = '1.0.11beta2';
PNG_LIBPNG_VER_STRING = '1.0.11beta3';
PNG_LIBPNG_VER = 10011;
type

View File

@ -2,7 +2,7 @@
; PNG.LIB module definition file for OS/2
;----------------------------------------
; Version 1.0.11beta2
; Version 1.0.11beta3
LIBRARY PNG
DESCRIPTION "PNG image compression library for OS/2"