[devel] Adjusted some whitespace in pngset.c

This commit is contained in:
Glenn Randers-Pehrson 2010-10-23 08:48:51 -05:00
parent c508081afc
commit 62333ba0cb

View File

@ -142,11 +142,13 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)
} }
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
/* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in
* version 1.2.1 * version 1.2.1
*/ */
png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)); PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16));
if (png_ptr->hist == NULL) if (png_ptr->hist == NULL)
{ {
png_warning(png_ptr, "Insufficient memory for hIST chunk data"); png_warning(png_ptr, "Insufficient memory for hIST chunk data");
@ -158,7 +160,6 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)
info_ptr->hist = png_ptr->hist; info_ptr->hist = png_ptr->hist;
info_ptr->valid |= PNG_INFO_hIST; info_ptr->valid |= PNG_INFO_hIST;
info_ptr->free_me |= PNG_FREE_HIST; info_ptr->free_me |= PNG_FREE_HIST;
} }
#endif #endif
@ -201,8 +202,8 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
/* Check for potential overflow */ /* Check for potential overflow */
if (width > (PNG_UINT_32_MAX if (width >
>> 3) /* 8-byte RRGGBBAA pixels */ (PNG_UINT_32_MAX >> 3) /* 8-byte RRGGBBAA pixels */
- 48 /* bigrowbuf hack */ - 48 /* bigrowbuf hack */
- 1 /* filter byte */ - 1 /* filter byte */
- 7*8 /* rounding of width to multiple of 8 pixels */ - 7*8 /* rounding of width to multiple of 8 pixels */
@ -259,6 +260,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
png_error(png_ptr, "Invalid format for pCAL parameter"); png_error(png_ptr, "Invalid format for pCAL parameter");
info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->pcal_purpose == NULL) if (info_ptr->pcal_purpose == NULL)
{ {
png_warning(png_ptr, "Insufficient memory for pCAL purpose"); png_warning(png_ptr, "Insufficient memory for pCAL purpose");
@ -278,11 +280,13 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
(unsigned long)length); (unsigned long)length);
info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->pcal_units == NULL) if (info_ptr->pcal_units == NULL)
{ {
png_warning(png_ptr, "Insufficient memory for pCAL units"); png_warning(png_ptr, "Insufficient memory for pCAL units");
return; return;
} }
png_memcpy(info_ptr->pcal_units, units, length); png_memcpy(info_ptr->pcal_units, units, length);
info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
@ -391,8 +395,10 @@ png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width,
/* Check the arguments. */ /* Check the arguments. */
if (width <= 0) if (width <= 0)
png_warning(png_ptr, "Invalid sCAL width ignored"); png_warning(png_ptr, "Invalid sCAL width ignored");
else if (height <= 0) else if (height <= 0)
png_warning(png_ptr, "Invalid sCAL height ignored"); png_warning(png_ptr, "Invalid sCAL height ignored");
else else
{ {
/* Convert 'width' and 'height' to ASCII. */ /* Convert 'width' and 'height' to ASCII. */
@ -419,8 +425,10 @@ png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit,
/* Check the arguments. */ /* Check the arguments. */
if (width <= 0) if (width <= 0)
png_warning(png_ptr, "Invalid sCAL width ignored"); png_warning(png_ptr, "Invalid sCAL width ignored");
else if (height <= 0) else if (height <= 0)
png_warning(png_ptr, "Invalid sCAL height ignored"); png_warning(png_ptr, "Invalid sCAL height ignored");
else else
{ {
/* Convert 'width' and 'height' to ASCII. */ /* Convert 'width' and 'height' to ASCII. */
@ -570,11 +578,13 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(name)+1; length = png_strlen(name)+1;
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length); new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
if (new_iccp_name == NULL) if (new_iccp_name == NULL)
{ {
png_warning(png_ptr, "Insufficient memory to process iCCP chunk"); png_warning(png_ptr, "Insufficient memory to process iCCP chunk");
return; return;
} }
png_memcpy(new_iccp_name, name, length); png_memcpy(new_iccp_name, name, length);
new_iccp_profile = (png_bytep)png_malloc_warn(png_ptr, proflen); new_iccp_profile = (png_bytep)png_malloc_warn(png_ptr, proflen);
@ -874,6 +884,7 @@ png_set_sPLT(png_structp png_ptr,
* entries - array of png_sPLT_t structures * entries - array of png_sPLT_t structures
* to be added to the list of palettes * to be added to the list of palettes
* in the info structure. * in the info structure.
*
* nentries - number of palette structures to be * nentries - number of palette structures to be
* added. * added.
*/ */
@ -980,6 +991,7 @@ png_set_unknown_chunks(png_structp png_ptr,
png_memcpy(to->name, from->name, png_sizeof(from->name)); png_memcpy(to->name, from->name, png_sizeof(from->name));
to->name[png_sizeof(to->name)-1] = '\0'; to->name[png_sizeof(to->name)-1] = '\0';
to->size = from->size; to->size = from->size;
/* Note our location in the read or write sequence */ /* Note our location in the read or write sequence */
to->location = (png_byte)(png_ptr->mode & 0xff); to->location = (png_byte)(png_ptr->mode & 0xff);
@ -1061,12 +1073,13 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep
return; return;
} }
if (chunk_list == NULL) if (chunk_list == NULL)
return; return;
old_num_chunks = png_ptr->num_chunk_list; old_num_chunks = png_ptr->num_chunk_list;
new_list=(png_bytep)png_malloc(png_ptr, new_list=(png_bytep)png_malloc(png_ptr,
(png_size_t) (png_size_t)(5*(num_chunks + old_num_chunks)));
(5*(num_chunks + old_num_chunks)));
if (png_ptr->chunk_list != NULL) if (png_ptr->chunk_list != NULL)
{ {
@ -1129,16 +1142,19 @@ png_set_compression_buffer_size(png_structp png_ptr, png_size_t size)
return; return;
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
if (size > ZLIB_IO_MAX) if (size > ZLIB_IO_MAX)
{ {
png_warning(png_ptr, "Attempt to set buffer size beyond max ignored"); png_warning(png_ptr, "Attempt to set buffer size beyond max ignored");
png_ptr->zbuf_size = ZLIB_IO_MAX; png_ptr->zbuf_size = ZLIB_IO_MAX;
size = ZLIB_IO_MAX; /* must fit */ size = ZLIB_IO_MAX; /* must fit */
} }
else else
png_ptr->zbuf_size = (uInt)size; png_ptr->zbuf_size = (uInt)size;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
/* The following ensures a relatively safe failure if this gets called while /* The following ensures a relatively safe failure if this gets called while
* the buffer is actually in use. * the buffer is actually in use.
*/ */