[libpng17] Implemented assert support and usage.

This commit is contained in:
John Bowler 2015-03-20 16:39:56 -05:00 committed by Glenn Randers-Pehrson
parent e8e7b6681e
commit 2460d9494d
20 changed files with 336 additions and 50 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.7.0beta58 - March 17, 2015
Libpng 1.7.0beta58 - March 20, 2015
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.
@ -757,7 +757,8 @@ Version 1.7.0beta57 [March 16, 2015]
in libpng-1.6.17beta01 (John Bowler).
Revert change to png_default_read_data() made in libpng-1.7.0beta55.
Version 1.7.0beta58 [March 17, 2015]
Version 1.7.0beta58 [March 20, 2015]
Implemented assert support and usage.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -5047,7 +5047,8 @@ Version 1.7.0beta57 [March 16, 2015]
in libpng-1.6.17beta01 (John Bowler).
Revert change to png_default_read_data() made in libpng-1.7.0beta55.
Version 1.7.0beta58 [March 17, 2015]
Version 1.7.0beta58 [March 20, 2015]
Implemented assert support and usage.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -15,6 +15,7 @@
#define _POSIX_SOURCE 1
#include "../pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_arm_arm_init
#ifdef PNG_READ_SUPPORTED

View File

@ -13,6 +13,7 @@
*/
#include "../pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_arm_filter_neon_intrinsics
#ifdef PNG_READ_SUPPORTED

14
png.c
View File

@ -12,6 +12,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_png
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_7_0beta58 Your_png_h_is_not_version_1_7_0beta58;
@ -688,13 +689,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.7.0beta58 - March 17, 2015" PNG_STRING_NEWLINE \
"libpng version 1.7.0beta58 - March 20, 2015" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
return "libpng version 1.7.0beta58 - March 17, 2015\
return "libpng version 1.7.0beta58 - March 20, 2015\
Copyright (c) 1998-2015 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@ -1610,7 +1611,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr,
* want error reports so for the moment it is an error.
*/
colorspace->flags |= PNG_COLORSPACE_INVALID;
png_error(png_ptr, "internal error checking chromaticities");
impossible("error checking chromaticities");
break;
}
@ -1638,7 +1639,7 @@ png_colorspace_set_endpoints(png_const_structrp png_ptr,
default:
colorspace->flags |= PNG_COLORSPACE_INVALID;
png_error(png_ptr, "internal error checking chromaticities");
impossible("error checking chromaticities");
break;
}
@ -2341,8 +2342,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
/* Check for an internal error. */
if (r+g+b != 32768)
png_error(png_ptr,
"internal error handling cHRM coefficients");
impossible("error handling cHRM coefficients");
else
{
@ -2356,7 +2356,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
* bug is fixed.
*/
else
png_error(png_ptr, "internal error handling cHRM->XYZ");
impossible("error handling cHRM->XYZ");
}
}
#endif /* READ_RGB_TO_GRAY */

View File

@ -17,6 +17,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngerror
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
@ -129,6 +130,7 @@ png_safecat(png_charp buffer, size_t bufsize, size_t pos,
* and end pointer (which should point just *beyond* the end of the buffer!)
* Returns the pointer to the start of the formatted string.
*/
#define PNG_HAVE_FORMAT_NUMBER /* for the code below */
png_charp
png_format_number(png_const_charp start, png_charp end, int format,
png_alloc_size_t number)
@ -647,9 +649,9 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
/* This is an internal error in libpng: somehow we have been left
* with a stack allocated jmp_buf when the application regained
* control. It's always possible to fix this up, but for the moment
* this is a png_error because that makes it easy to detect.
* this is an assert because that makes it easy to detect.
*/
png_error(png_ptr, "Libpng jmp_buf still allocated");
impossible("Libpng jmp_buf still allocated");
/* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */
}
}
@ -970,4 +972,175 @@ png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
return result;
}
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
/* Asserts: minimal code in 'STABLE' builds to return control to the
* application, more verbose code followed by abort for all other builds to
* ensure that internal errors are detected.
*
* The code always produces a message if it is possible, regardless of the
* setting of PNG_ERROR_TEXT_SUPPORTED, except that in stable builds
* PNG_ERROR_TEXT_SUPPORTED is honoured. See pngpriv.h for the calculation of
* the two control macros PNG_ASSERT_ERROR (don't abort; stable build or rc) and
* PNG_ASSERT_TEXT (output text.)
*/
#if PNG_ASSERT_TEXT
# ifdef PNG_HAVE_FORMAT_NUMBER
static size_t
png_assert_number(png_charp buffer, size_t bufsize, size_t pos,
unsigned int number, int format)
{
char numbuf[PNG_NUMBER_BUFFER_SIZE];
return png_safecat(buffer, bufsize, pos,
png_format_number(numbuf, numbuf + sizeof numbuf, format, number));
}
# define assert_number(a,b,c,d,e) png_assert_number(a,b,c,d,e)
# else /* !HAVE_FORMAT_NUMBER */
static size_t
png_assert_number(png_charp buffer, size_t bufsize, size_t pos,
unsigned int number)
{
/* binhex it; highly non-portable, assumes the ASCII character set, but
* if warnings are turned off then it is unlikely the text will get read
* anyway. This binhex variant is (48+val), where 'val' is the next 6
* bits of the number, so it starts as '0' (for 0) and ends at 'I' for
* 63. The number is wrapped in {}, so 0 comes out as '{}' and 9 comes
* out as '{9}' and so on.
*/
char numbuf[32];
int i = sizeof numbuf;
numbuf[--i] = 0;
numbuf[--i] = '}';
do
{
if (number > 0)
numbuf[--i] = (char)/*SAFE*/((number & 63) + 48), number >>= 6;
else
{
numbuf[--i] = '{';
break;
}
}
while (i > 0);
return png_safecat(buffer, bufsize, pos, numbuf+i);
}
# define assert_number(a,b,c,d,e) png_assert_number(a,b,c,d)
#endif /* !HAVE_FORMAT_NUMBER */
#endif /* ASSERT_TEXT */
#if PNG_ASSERT_ERROR
PNG_FUNCTION(void, png_assert,(png_const_structrp png_ptr,
unsigned int position), PNG_NORETURN)
#else
PNG_FUNCTION(void, png_assert,(png_const_structrp png_ptr,
png_const_charp condition, unsigned int position), PNG_NORETURN)
#endif
{
# if PNG_ASSERT_TEXT
/* Format the 'position' number and output:
*
* " libpng version <version> - <date>\n"
* " translated __DATE__ __TIME__\n"
* " <file>, <line>: assert 'condition' failed"
*
* In the STABLE versions the output is the same for the first two lines
* but the last line becomes:
*
* " <position>: assert failed"
*
* If there is no number formatting the numbers just get replaced by
* some binhex (see the utility above).
*/
size_t pos;
char buffer[256];
pos = png_safecat(buffer, sizeof buffer, 0, PNG_HEADER_VERSION_STRING);
pos = png_safecat(buffer, sizeof buffer, pos,
" translated " __DATE__ " " __TIME__ "\n ");
# if PNG_ASSERT_ERROR /* no 'condition' parameter: minimal text */
pos = assert_number(buffer, sizeof buffer, pos, position,
PNG_NUMBER_FORMAT_x);
pos = png_safecat(buffer, sizeof buffer, pos, ": assert failed");
# else /* !STABLE */
/* Break down 'position' into a file name and a line number: */
{
# define PNG_apply(f) { #f "\0", PNG_SRC_FILE_ ## f },
# define PNG_end { "", PNG_SRC_FILE_LAST }
static struct {
char filename[28]; /* GCC checks this size */
unsigned int base;
} fileinfo[] = { PNG_FILES };
# undef PNG_apply
# undef PNG_end
unsigned int i;
png_const_charp filename;
/* Do 'nfiles' this way to avoid problems with g++ where it whines
* about (size_t) being larger than (int), even though this is a
* compile time constant:
*/
# define nfiles ((sizeof fileinfo)/(sizeof (fileinfo[0])))
for (i=0; i < nfiles && position > fileinfo[i].base; ++i) {}
if (i == 0 || i > nfiles)
filename = "UNKNOWN";
else
{
filename = fileinfo[i-1].filename;
position -= fileinfo[i-1].base;
}
# undef nfiles
pos = png_safecat(buffer, sizeof buffer, pos, filename);
pos = png_safecat(buffer, sizeof buffer, pos, ".c, ");
pos = assert_number(buffer, sizeof buffer, pos, position,
PNG_NUMBER_FORMAT_u);
}
pos = png_safecat(buffer, sizeof buffer, pos, ": assert '");
pos = png_safecat(buffer, sizeof buffer, pos, condition);
pos = png_safecat(buffer, sizeof buffer, pos, "' failed");
# endif /* !STABLE */
# else /* !ASSERT_TEXT */
PNG_UNUSED(position)
# if !PNG_ASSERT_ERROR
PNG_UNUSED(condition)
# endif
# endif /* HAVE_ASSERT_TEXT */
/* Now in STABLE do a png_error, but in other builds output the message
* (if possible) then abort (PNG_ABORT).
*/
# if PNG_ASSERT_ERROR
png_error(png_ptr, buffer/*only if ERROR_TEXT*/);
# else /* !ASSERT_ERROR */
/* Use the app warning message mechanism is possible, this is an inline
* expansion of png_warning without the extra formatting of the message
* that png_default_warning does and with the case !WARNINGS && CONSOLE_IO
* implemented.
*
* Note that it is possible that neither WARNINGS nor CONSOLE_IO are
* supported; in that case no text will be output (and PNG_ASSERT_TEXT
* will be false.)
*/
# ifdef PNG_WARNINGS_SUPPORTED
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
png_ptr->warning_fn(png_constcast(png_structrp,png_ptr), buffer);
# ifdef PNG_CONSOLE_IO_SUPPORTED
else
# endif
# else
PNG_UNUSED(png_ptr)
# endif
# ifdef PNG_CONSOLE_IO_SUPPORTED
fprintf(stderr, "%s\n", buffer);
# endif
PNG_ABORT
# endif /* ASSERT_ERROR */
}
#endif /* READ || WRITE */

View File

@ -13,6 +13,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngget
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)

View File

@ -18,6 +18,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngmem
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Free a png_struct */
@ -119,9 +120,7 @@ PNG_FUNCTION(png_voidp /* PRIVATE */,
png_malloc_array,(png_const_structrp png_ptr, int nelements,
size_t element_size),PNG_ALLOCATED)
{
if (nelements <= 0 || element_size == 0)
png_error(png_ptr, "internal error: array alloc");
assert(nelements > 0 && element_size > 0);
return png_malloc_array_checked(png_ptr, nelements, element_size);
}
@ -130,9 +129,8 @@ png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
{
/* These are internal errors: */
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
(old_array == NULL && old_elements > 0))
png_error(png_ptr, "internal error: array realloc");
assert(add_elements > 0 && element_size > 0 && old_elements >= 0 &&
(old_array != NULL || old_elements == 0));
/* Check for overflow on the elements count (so the caller does not have to
* check.)

View File

@ -12,6 +12,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngpread
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
@ -711,8 +712,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
png_size_t buffer_length)
{
/* The caller checks for a non-zero buffer length. */
if (!(buffer_length > 0) || buffer == NULL)
png_error(png_ptr, "No IDAT data (internal error)");
assert(buffer_length > 0 && buffer != NULL);
/* This routine must process all the data it has been given
* before returning, calling the row callback as required to

123
pngpriv.h
View File

@ -332,17 +332,116 @@
# define PNG_DLL_EXPORT
#endif
/* asserts are turned off in release code, but are in even in release candidates
* because often system builders only check future libpng releases when a
* release candidate is available.
/* The assert mechanism results in a minimal png_error in released versions
* ('STABLE' versions) and a more descriptive abort in all other cases.
* The macros rely on the naming convention throughout this code - png_ptr
* exists and is of type png_const_structrp or a compatible type - and the
* presence in each file of a uniquely defined macro PNG_SRC_FILE; a number
* indicating which file this is (this is to save space in released versions).
*
* 'assert' is intended to look like the ANSI-C <assert.h> macro; note that this
* is legal ANSI-C code because ANSI-C only reserves 'assert' if <assert.h> is
* included. Doing it this way allows <assert.h> to be used if the ANSI-C
* behavior is preferred in the future.
*
* PNG_SRC_LINE is the position of the assert macro. There are currently 15
* main source files (4 bits) and the biggest (pngrtran.c) has more than 4095
* lines (12 bits), but to ensure the number will fit into 16-bits in the
* future and to allow hardware files to use assert the encoding is a bit-wise
* encoding based on the current number of lines.
*
* The following works out the value for two numeric #defines:
*
* PNG_ASSERT_ERROR: Set to 1 if asserts should png_error (or png_err) rather
* than abort. The png_error text is the minimal (file
* location) text in this case, if it is produced. This
* flag indicates a STABLE (or RC) build.
* PNG_ASSERT_TEXT: Set to 1 if assert text should be produced, either the
* minimal text or, if PNG_ASSERT_ERROR is 0, the more
* verbose text including the 'condition' string. This
* value depends on whether the build supports an
* appropriate way of outputing the message.
*
* Note that these are not configurable: this is just the assert code, there's
* no reason to allow configuration of these options.
*/
#if PNG_LIBPNG_BUILD_BASE_TYPE == PNG_LIBPNG_BUILD_STABLE
# define NDEBUG
#endif
#ifndef PNG_VERSION_INFO_ONLY
# include <assert.h>
#define PNG_ASSERT_ERROR (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC)
#define PNG_ASSERT_TEXT (PNG_ASSERT_ERROR ?\
(defined PNG_ERROR_TEXT_SUPPORTED) :\
(defined PNG_WARNINGS_SUPPORTED) || (defined PNG_CONSOLE_IO_SUPPORTED))
#define PNG_SRC_LINE (PNG_SRC_FILE + __LINE__)
/* png_assertpp and png_impossiblepp are macros to make the correct call to the
* png_assert function; these macros do not assume that the png_structp is
* called png_ptr.
*/
#if PNG_ASSERT_ERROR
# define png_assertpp(pp, cond)\
do\
if (!(cond)) png_assert(pp, PNG_SRC_LINE);\
while (0)
# define png_impossiblepp(pp, reason) png_assert(pp, PNG_SRC_LINE)
#else
# define png_assertpp(pp, cond)\
do\
if (!(cond)) png_assert(pp, #cond, PNG_SRC_LINE);\
while (0)
# define png_impossiblepp(pp, reason) png_assert(pp, reason, PNG_SRC_LINE)
#endif
#define assert(cond) png_assertpp(png_ptr, cond)
#define impossible(cond) png_impossiblepp(png_ptr, cond)
/* The defines for PNG_SRC_FILE: */
#define PNG_SRC_FILE_(f,lines) PNG_SRC_FILE_ ## f + lines
#define PNG_SRC_FILE_png 0
#define PNG_SRC_FILE_pngerror (PNG_SRC_FILE_png +8192)
#define PNG_SRC_FILE_pngget (PNG_SRC_FILE_pngerror +2048)
#define PNG_SRC_FILE_pngmem (PNG_SRC_FILE_pngget +2048)
#define PNG_SRC_FILE_pngpread (PNG_SRC_FILE_pngmem +1024)
#define PNG_SRC_FILE_pngread (PNG_SRC_FILE_pngpread +2048)
#define PNG_SRC_FILE_pngrio (PNG_SRC_FILE_pngread +8192)
#define PNG_SRC_FILE_pngrtran (PNG_SRC_FILE_pngrio +1024)
#define PNG_SRC_FILE_pngrutil (PNG_SRC_FILE_pngrtran +8192)
#define PNG_SRC_FILE_pngset (PNG_SRC_FILE_pngrutil +8192)
#define PNG_SRC_FILE_pngtrans (PNG_SRC_FILE_pngset +2048)
#define PNG_SRC_FILE_pngwio (PNG_SRC_FILE_pngtrans +2048)
#define PNG_SRC_FILE_pngwrite (PNG_SRC_FILE_pngwio +1024)
#define PNG_SRC_FILE_pngwtran (PNG_SRC_FILE_pngwrite +4096)
#define PNG_SRC_FILE_pngwutil (PNG_SRC_FILE_pngwtran +1024)
#define PNG_SRC_FILE_arm_arm_init (PNG_SRC_FILE_pngwutil +4096)
#define PNG_SRC_FILE_arm_filter_neon_intrinsics\
(PNG_SRC_FILE_arm_arm_init +1024)
/* Add new files by changing the following line: */
#define PNG_SRC_FILE_LAST (PNG_SRC_FILE_arm_filter_neon_intrinsics +1024)
/* The following #define must list the files in exactly the same order as
* the above.
*/
#define PNG_FILES\
PNG_apply(png)\
PNG_apply(pngerror)\
PNG_apply(pngget)\
PNG_apply(pngmem)\
PNG_apply(pngpread)\
PNG_apply(pngread)\
PNG_apply(pngrio)\
PNG_apply(pngrtran)\
PNG_apply(pngrutil)\
PNG_apply(pngset)\
PNG_apply(pngtrans)\
PNG_apply(pngwio)\
PNG_apply(pngwrite)\
PNG_apply(pngwtran)\
PNG_apply(pngwutil)\
PNG_apply(arm_arm_init)\
PNG_apply(arm_filter_neon_intrinsics)\
PNG_end
/* SECURITY and SAFETY:
*
* libpng is built with support for internal limits on image dimensions and
@ -727,6 +826,14 @@ extern "C" {
*
* All of these functions must be declared with PNG_INTERNAL_FUNCTION.
*/
/* Assert handling */
#if PNG_ASSERT_ERROR
PNG_INTERNAL_FUNCTION(void, png_assert,(png_const_structrp png_ptr,
unsigned int position), PNG_NORETURN);
#else
PNG_INTERNAL_FUNCTION(void, png_assert,(png_const_structrp png_ptr,
png_const_charp condition, unsigned int position), PNG_NORETURN);
#endif
/* Zlib support */
#define PNG_UNEXPECTED_ZLIB_RETURN (-7)

View File

@ -18,6 +18,7 @@
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
# include <errno.h>
#endif
#define PNG_SRC_FILE PNG_SRC_FILE_pngread
#ifdef PNG_READ_SUPPORTED
@ -1684,8 +1685,8 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding)
break;
default:
png_error(display->image->opaque->png_ptr,
"unexpected encoding (internal error)");
png_impossiblepp(display->image->opaque->png_ptr,
"unexpected encoding");
break;
}
@ -1840,7 +1841,7 @@ png_create_colormap_entry(png_image_read_control *display,
}
if (encoding != output_encoding)
png_error(image->opaque->png_ptr, "bad encoding (internal error)");
png_impossiblepp(image->opaque->png_ptr, "bad encoding");
/* Store the value. */
{
@ -2847,7 +2848,7 @@ png_image_read_colormap(png_voidp argument)
switch (data_encoding)
{
default:
png_error(png_ptr, "bad data option (internal error)");
impossible("bad data option");
break;
case P_sRGB:
@ -2861,8 +2862,7 @@ png_image_read_colormap(png_voidp argument)
break;
}
if (cmap_entries > 256 || cmap_entries > image->colormap_entries)
png_error(png_ptr, "color map overflow (BAD internal error)");
assert(cmap_entries <= 256 && cmap_entries <= image->colormap_entries);
image->colormap_entries = cmap_entries;
@ -2896,10 +2896,10 @@ png_image_read_colormap(png_voidp argument)
break;
default:
png_error(png_ptr, "bad processing option (internal error)");
impossible("bad processing option");
bad_background:
png_error(png_ptr, "bad background index (internal error)");
impossible("bad background index");
}
display->colormap_processing = output_processing;
@ -3172,7 +3172,7 @@ png_image_read_colormapped(png_voidp argument)
default:
bad_output:
png_error(png_ptr, "bad color-map processing (internal error)");
impossible("bad color-map processing");
}
/* Now read the rows. Do this here if it is possible to read directly into
@ -3957,8 +3957,8 @@ png_image_read_direct(png_voidp argument)
}
}
else if (do_local_compose != 0) /* internal error */
png_error(png_ptr, "png_image_read: alpha channel lost");
else
assert(do_local_compose == 0 /* else alpha channel lost */);
if (info_ptr->bit_depth == 16)
info_format |= PNG_FORMAT_FLAG_LINEAR;
@ -3987,8 +3987,7 @@ png_image_read_direct(png_voidp argument)
# endif
/* This is actually an internal error. */
if (info_format != format)
png_error(png_ptr, "png_read_image: invalid transformations");
assert(info_format == format /* else unimplemented transformations */);
}
/* Now read the rows. If do_local_compose is set then it is necessary to use

View File

@ -19,6 +19,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_rio
#ifdef PNG_READ_SUPPORTED

View File

@ -17,6 +17,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngrtran
#ifdef PNG_READ_SUPPORTED
@ -1271,11 +1272,8 @@ png_init_background_transformations(png_structrp png_ptr)
* than the libpng required depth scale the values back to the 8-bit
* range, the test below verifies that this is correct.
*/
if (bit_depth > required_bit_depth)
{
if (bit_depth != 16 || required_bit_depth != 8)
png_error(png_ptr, "internal error handling background depth");
}
assert(bit_depth <= required_bit_depth ||
(bit_depth == 16 && required_bit_depth == 8));
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
{

View File

@ -15,6 +15,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngrutil
#ifdef PNG_READ_SUPPORTED

View File

@ -17,6 +17,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngset
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)

View File

@ -12,6 +12,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngtrans
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)

View File

@ -19,6 +19,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngwio
#ifdef PNG_WRITE_SUPPORTED

View File

@ -15,6 +15,7 @@
#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
# include <errno.h>
#endif
#define PNG_SRC_FILE PNG_SRC_FILE_pngwrite
#ifdef PNG_WRITE_SUPPORTED

View File

@ -12,6 +12,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngwtran
#ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED

View File

@ -12,6 +12,7 @@
*/
#include "pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_pngwutil
#ifdef PNG_WRITE_SUPPORTED
@ -662,8 +663,7 @@ png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp)
}
/* This is an internal error; 'next' must have been NULL! */
if (output_len > 0)
png_error(png_ptr, "error writing ancillary chunked compressed data");
assert(output_len == 0);
}
#endif /* WRITE_COMPRESSED_TEXT */
@ -1204,8 +1204,7 @@ png_write_iCCP(png_structrp png_ptr, png_const_charp name,
/* These are all internal problems: the profile should have been checked
* before when it was stored.
*/
if (profile == NULL)
png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */
assert(profile != NULL);
profile_len = png_get_uint_32(profile);