mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng17] Merge recent changes from libpng-1.6.14beta06:
Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa Removed unused "text_len" parameter from private function png_write_zTXt(). Conditionally compile some code in png_deflate_claim(), when PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled. Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL. Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT" to pnglibconf.dfa. Edit and fix typos in comments.
This commit is contained in:
parent
b2e89f1af6
commit
c7e743d385
11
ANNOUNCE
11
ANNOUNCE
@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.7.0beta38 - September 28, 2014
|
||||
Libpng 1.7.0beta38 - October 4, 2014
|
||||
|
||||
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.
|
||||
@ -602,7 +602,14 @@ Version 1.7.0beta36 [September 27, 2014]
|
||||
Version 1.7.0beta37 [September 28, 2014]
|
||||
Merged scripts/*, pngvalid.c and pngfix.c with libpng-1.6.14beta04.
|
||||
|
||||
Version 1.7.0beta38 [September 28, 2014]
|
||||
Version 1.7.0beta38 [October 4, 2014]
|
||||
Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
|
||||
Removed unused "text_len" parameter from private function png_write_zTXt().
|
||||
Conditionally compile some code in png_deflate_claim(), when
|
||||
PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
|
||||
Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
|
||||
Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
|
||||
to pnglibconf.dfa.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
9
CHANGES
9
CHANGES
@ -4891,7 +4891,14 @@ Version 1.7.0beta36 [September 27, 2014]
|
||||
Version 1.7.0beta37 [September 28, 2014]
|
||||
Merged scripts/*, pngvalid.c and pngfix.c with libpng-1.6.14beta04.
|
||||
|
||||
Version 1.7.0beta38 [September 28, 2014]
|
||||
Version 1.7.0beta38 [October 4, 2014]
|
||||
Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
|
||||
Removed unused "text_len" parameter from private function png_write_zTXt().
|
||||
Conditionally compile some code in png_deflate_claim(), when
|
||||
PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
|
||||
Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
|
||||
Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
|
||||
to pnglibconf.dfa.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
12
png.c
12
png.c
@ -696,13 +696,13 @@ png_get_copyright(png_const_structrp png_ptr)
|
||||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.7.0beta38 - September 28, 2014" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.7.0beta38 - October 4, 2014" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2014 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.0beta38 - September 28, 2014\
|
||||
return "libpng version 1.7.0beta38 - October 4, 2014\
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
@ -3474,8 +3474,8 @@ png_log16bit(png_uint_32 x)
|
||||
* each case only the low 16 bits are relevant - the fraction - since the
|
||||
* integer bits (the top 4) simply determine a shift.
|
||||
*
|
||||
* The worst case is the 16-bit distinction between 65535 and 65534, this
|
||||
* requires perhaps spurious accuracty in the decoding of the logarithm to
|
||||
* The worst case is the 16-bit distinction between 65535 and 65534. This
|
||||
* requires perhaps spurious accuracy in the decoding of the logarithm to
|
||||
* distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance
|
||||
* of getting this accuracy in practice.
|
||||
*
|
||||
@ -3563,7 +3563,7 @@ png_exp8bit(png_fixed_point lg2)
|
||||
/* Get a 32-bit value: */
|
||||
png_uint_32 x = png_exp(lg2);
|
||||
|
||||
/* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the
|
||||
/* Convert the 32-bit value to 0..255 by multiplying by 256-1. Note that the
|
||||
* second, rounding, step can't overflow because of the first, subtraction,
|
||||
* step.
|
||||
*/
|
||||
@ -4165,7 +4165,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
|
||||
*
|
||||
* error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact
|
||||
*
|
||||
* In all cases the inexact readings are off by one.
|
||||
* In all cases the inexact readings are only off by one.
|
||||
*/
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
|
195
pngpread.c
195
pngpread.c
@ -26,6 +26,13 @@
|
||||
#define PNG_READ_iTXt_MODE 7
|
||||
#define PNG_ERROR_MODE 8
|
||||
|
||||
#define PNG_PUSH_SAVE_BUFFER_IF_FULL \
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size) \
|
||||
{ png_push_save_buffer(png_ptr); return; }
|
||||
#define PNG_PUSH_SAVE_BUFFER_IF_LT_N(N) \
|
||||
if (png_ptr->buffer_size < N) \
|
||||
{ png_push_save_buffer(png_ptr); return; }
|
||||
|
||||
void PNGAPI
|
||||
png_process_data(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep buffer, png_size_t buffer_size)
|
||||
@ -46,7 +53,7 @@ png_process_data_pause(png_structrp png_ptr, int save)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* It's easiest for the caller if we do the save, then the caller doesn't
|
||||
/* It's easiest for the caller if we do the save; then the caller doesn't
|
||||
* have to supply the same data again:
|
||||
*/
|
||||
if (save != 0)
|
||||
@ -189,10 +196,10 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
int keep; /* unknown handling method */
|
||||
#endif
|
||||
|
||||
/* First we make sure we have enough data for the 4 byte chunk name
|
||||
* and the 4 byte chunk length before proceeding with decoding the
|
||||
/* First we make sure we have enough data for the 4-byte chunk name
|
||||
* and the 4-byte chunk length before proceeding with decoding the
|
||||
* chunk data. To fully decode each of these chunks, we also make
|
||||
* sure we have enough data in the buffer for the 4 byte CRC at the
|
||||
* sure we have enough data in the buffer for the 4-byte CRC at the
|
||||
* end of every chunk (except IDAT, which is handled separately).
|
||||
*/
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||
@ -200,12 +207,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_byte chunk_length[4];
|
||||
png_byte chunk_tag[4];
|
||||
|
||||
if (png_ptr->buffer_size < 8)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT_N(8)
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
@ -249,23 +251,13 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
if (png_ptr->push_length != 13)
|
||||
png_error(png_ptr, "Invalid IHDR length");
|
||||
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
else if (chunk_name == png_IEND)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
|
||||
|
||||
png_ptr->process_mode = PNG_READ_DONE_MODE;
|
||||
@ -275,12 +267,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
|
||||
|
||||
if (chunk_name == png_PLTE)
|
||||
@ -290,11 +277,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
else if (chunk_name == png_PLTE)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -313,12 +296,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_gAMA)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -326,12 +304,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_sBIT_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_sBIT)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -339,12 +312,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_cHRM)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -352,12 +320,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
else if (chunk_name == png_sRGB)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -365,12 +328,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_iCCP)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -378,12 +336,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
else if (chunk_name == png_sPLT)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -391,12 +344,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
else if (chunk_name == png_tRNS)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -404,12 +352,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_bKGD_SUPPORTED
|
||||
else if (chunk_name == png_bKGD)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -417,12 +360,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
else if (chunk_name == png_hIST)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -430,12 +368,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
else if (chunk_name == png_pHYs)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -443,12 +376,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_oFFs_SUPPORTED
|
||||
else if (chunk_name == png_oFFs)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
@ -456,12 +384,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_pCAL_SUPPORTED
|
||||
else if (chunk_name == png_pCAL)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -469,12 +392,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_sCAL_SUPPORTED
|
||||
else if (chunk_name == png_sCAL)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -482,12 +400,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_tIME_SUPPORTED
|
||||
else if (chunk_name == png_tIME)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -495,12 +408,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
else if (chunk_name == png_tEXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -508,12 +416,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
else if (chunk_name == png_zTXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@ -521,23 +424,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
else if (chunk_name == png_iTXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
}
|
||||
@ -602,12 +496,7 @@ png_push_crc_finish(png_structrp png_ptr)
|
||||
}
|
||||
if (!png_ptr->skip_length)
|
||||
{
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT_N(4)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
}
|
||||
@ -732,12 +621,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
png_byte chunk_tag[4];
|
||||
|
||||
/* TODO: this code can be commoned up with the same code in push_read */
|
||||
if (png_ptr->buffer_size < 8)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT_N(8)
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
@ -812,12 +696,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
}
|
||||
if (!png_ptr->idat_size)
|
||||
{
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT_N(4)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
@ -998,7 +998,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_WRITE_zTXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp
|
||||
key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);
|
||||
key, png_const_charp text, int compression),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_iTXt_SUPPORTED
|
||||
|
12
pngset.c
12
pngset.c
@ -727,7 +727,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
|
||||
else
|
||||
max_text = INT_MAX;
|
||||
|
||||
/* Now allocate a new array and copy the old members in, this does all
|
||||
/* Now allocate a new array and copy the old members in; this does all
|
||||
* the overflow checks.
|
||||
*/
|
||||
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
|
||||
@ -1061,8 +1061,8 @@ png_set_sPLT(png_structrp png_ptr,
|
||||
|
||||
np->depth = entries->depth;
|
||||
|
||||
/* In the even of out-of-memory just return - there's no point keeping on
|
||||
* trying to add sPLT chunks.
|
||||
/* In the event of out-of-memory just return - there's no point keeping
|
||||
* on trying to add sPLT chunks.
|
||||
*/
|
||||
length = strlen(entries->name) + 1;
|
||||
np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
|
||||
@ -1073,8 +1073,8 @@ png_set_sPLT(png_structrp png_ptr,
|
||||
memcpy(np->name, entries->name, length);
|
||||
|
||||
/* IMPORTANT: we have memory now that won't get freed if something else
|
||||
* goes wrong, this code must free it. png_malloc_array produces no
|
||||
* warnings, use a png_chunk_report (below) if there is an error.
|
||||
* goes wrong; this code must free it. png_malloc_array produces no
|
||||
* warnings; use a png_chunk_report (below) if there is an error.
|
||||
*/
|
||||
np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,
|
||||
entries->nentries, sizeof (png_sPLT_entry)));
|
||||
@ -1113,7 +1113,7 @@ check_location(png_const_structrp png_ptr, int location)
|
||||
location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);
|
||||
|
||||
/* New in 1.6.0; copy the location and check it. This is an API
|
||||
* change, previously the app had to use the
|
||||
* change; previously the app had to use the
|
||||
* png_set_unknown_chunk_location API below for each chunk.
|
||||
*/
|
||||
if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
|
@ -828,7 +828,7 @@ png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structrp png_ptr)
|
||||
{
|
||||
/* See the comments in png.h - this is the sub-image row when reading and
|
||||
/* See the comments in png.h - this is the sub-image row when reading an
|
||||
* interlaced image.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
|
@ -310,8 +310,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
#ifdef PNG_WRITE_zTXt_SUPPORTED
|
||||
/* Write compressed chunk */
|
||||
png_write_zTXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text, 0,
|
||||
info_ptr->text[i].compression);
|
||||
info_ptr->text[i].text, info_ptr->text[i].compression);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write compressed text");
|
||||
#endif
|
||||
@ -404,8 +403,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_WRITE_zTXt_SUPPORTED
|
||||
/* Write compressed chunk */
|
||||
png_write_zTXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text, 0,
|
||||
info_ptr->text[i].compression);
|
||||
info_ptr->text[i].text, info_ptr->text[i].compression);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write compressed text");
|
||||
#endif
|
||||
|
25
pngwutil.c
25
pngwutil.c
@ -136,7 +136,7 @@ png_write_chunk_data(png_structrp png_ptr, png_const_bytep data,
|
||||
png_write_data(png_ptr, data, length);
|
||||
|
||||
/* Update the CRC after writing the data,
|
||||
* in case that the user I/O routine alters it.
|
||||
* in case the user I/O routine alters it.
|
||||
*/
|
||||
png_calculate_crc(png_ptr, data, length);
|
||||
}
|
||||
@ -181,7 +181,7 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
|
||||
/* On 64 bit architectures 'length' may not fit in a png_uint_32. */
|
||||
if (length > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "length exceeds PNG maxima");
|
||||
png_error(png_ptr, "length exceeds PNG maximum");
|
||||
|
||||
png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);
|
||||
png_write_chunk_data(png_ptr, data, length);
|
||||
@ -204,7 +204,7 @@ png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,
|
||||
static png_alloc_size_t
|
||||
png_image_size(png_structrp png_ptr)
|
||||
{
|
||||
/* Only return sizes up to the maximum of a png_uint_32, do this by limiting
|
||||
/* Only return sizes up to the maximum of a png_uint_32; do this by limiting
|
||||
* the width and height used to 15 bits.
|
||||
*/
|
||||
png_uint_32 h = png_ptr->height;
|
||||
@ -297,6 +297,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
{
|
||||
if (png_ptr->zowner != 0)
|
||||
{
|
||||
# if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
char msg[64];
|
||||
|
||||
PNG_STRING_FROM_CHUNK(msg, owner);
|
||||
@ -308,6 +309,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
* are minimal.
|
||||
*/
|
||||
(void)png_safecat(msg, (sizeof msg), 10, " using zstream");
|
||||
# endif
|
||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
png_warning(png_ptr, msg);
|
||||
|
||||
@ -492,7 +494,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
int ret;
|
||||
|
||||
/* To find the length of the output it is necessary to first compress the
|
||||
* input, the result is buffered rather than using the two-pass algorithm
|
||||
* input. The result is buffered rather than using the two-pass algorithm
|
||||
* that is used on the inflate side; deflate is assumed to be slower and a
|
||||
* PNG writer is assumed to have more memory available than a PNG reader.
|
||||
*
|
||||
@ -589,7 +591,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
}
|
||||
while (ret == Z_OK);
|
||||
|
||||
/* There may be some space left in the last output buffer, this needs to
|
||||
/* There may be some space left in the last output buffer. This needs to
|
||||
* be subtracted from output_len.
|
||||
*/
|
||||
output_len -= png_ptr->zstream.avail_out;
|
||||
@ -612,7 +614,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
/* Reset zlib for another zTXt/iTXt or image data */
|
||||
png_ptr->zowner = 0;
|
||||
|
||||
/* The only success case is Z_STREAM_END, input_len must be 0, if not this
|
||||
/* The only success case is Z_STREAM_END, input_len must be 0; if not this
|
||||
* is an internal error.
|
||||
*/
|
||||
if (ret == Z_STREAM_END && input_len == 0)
|
||||
@ -728,6 +730,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
if (key_len == 0)
|
||||
return 0;
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* Try to only output one warning per keyword: */
|
||||
if (*key) /* keyword too long */
|
||||
png_warning(png_ptr, "keyword truncated");
|
||||
@ -741,6 +744,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
|
||||
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
return key_len;
|
||||
}
|
||||
@ -998,7 +1002,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
|
||||
* Z_FINISH: this is the end of the input, do a Z_FINISH and clean up
|
||||
*
|
||||
* The routine manages the acquire and release of the png_ptr->zstream by
|
||||
* checking and (at the end) clearing png_ptr->zowner, it does some sanity
|
||||
* checking and (at the end) clearing png_ptr->zowner; it does some sanity
|
||||
* checks on the 'mode' flags while doing this.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
@ -1058,7 +1062,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
||||
input_len += png_ptr->zstream.avail_in;
|
||||
png_ptr->zstream.avail_in = 0;
|
||||
|
||||
/* OUTPUT: write complete IDAT chunks when avail_out drops to zero, note
|
||||
/* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note
|
||||
* that these two zstream fields are preserved across the calls, therefore
|
||||
* there is no need to set these up on entry to the loop.
|
||||
*/
|
||||
@ -1090,7 +1094,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* The order of these checks doesn't matter much; it just effect which
|
||||
/* The order of these checks doesn't matter much; it just affects which
|
||||
* possible error might be detected if multiple things go wrong at once.
|
||||
*/
|
||||
if (ret == Z_OK) /* most likely return code! */
|
||||
@ -1623,14 +1627,13 @@ png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
|
||||
/* Write a compressed text chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
|
||||
png_size_t text_len, int compression)
|
||||
int compression)
|
||||
{
|
||||
png_uint_32 key_len;
|
||||
png_byte new_key[81];
|
||||
compression_state comp;
|
||||
|
||||
png_debug(1, "in png_write_zTXt");
|
||||
PNG_UNUSED(text_len) /* Always use strlen */
|
||||
|
||||
if (compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
{
|
||||
|
@ -740,7 +740,7 @@ chunk cHRM enables COLORSPACE
|
||||
chunk gAMA enables GAMMA
|
||||
chunk hIST
|
||||
chunk iCCP enables COLORSPACE, GAMMA
|
||||
chunk iTXt
|
||||
chunk iTXt enables TEXT
|
||||
chunk oFFs
|
||||
chunk pCAL
|
||||
chunk pHYs
|
||||
@ -751,7 +751,7 @@ chunk sRGB enables COLORSPACE, GAMMA, SET_OPTION
|
||||
chunk tEXt requires TEXT
|
||||
chunk tIME
|
||||
chunk tRNS
|
||||
chunk zTXt
|
||||
chunk zTXt enables TEXT
|
||||
|
||||
# This only affects support of the optional PLTE chunk in RGB and RGBA
|
||||
# images. Notice that READ_ANCILLARY_CHUNKS therefore disables part
|
||||
@ -835,9 +835,9 @@ option SAVE_INT_32 disabled
|
||||
option WRITE_OPTIMIZE_CMF requires WRITE
|
||||
|
||||
option READ_COMPRESSED_TEXT disabled
|
||||
option READ_iCCP enables READ_COMPRESSED_TEXT
|
||||
option READ_iTXt enables READ_COMPRESSED_TEXT
|
||||
option READ_zTXt enables READ_COMPRESSED_TEXT
|
||||
option READ_COMPRESSED_TEXT enables READ_TEXT
|
||||
|
||||
option WRITE_oFFs enables SAVE_INT_32
|
||||
option WRITE_pCAL enables SAVE_INT_32
|
||||
|
Loading…
x
Reference in New Issue
Block a user