[libpng16] Work around gcc 3.x and Microsoft Visual Studio 2010 complaints.
Both object to the split initialization of num_chunks.
This commit is contained in:
parent
ece07cfe9c
commit
aa9dea57d7
2
ANNOUNCE
2
ANNOUNCE
@ -439,6 +439,8 @@ Version 1.6.0beta27 [August 10, 2012]
|
||||
png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros.
|
||||
Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and
|
||||
png_memcmp() macros.
|
||||
Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object
|
||||
to the split initialization of num_chunks.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
2
CHANGES
2
CHANGES
@ -4190,6 +4190,8 @@ Version 1.6.0beta27 [August 10, 2012]
|
||||
png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros.
|
||||
Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and
|
||||
png_memcmp() macros.
|
||||
Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object
|
||||
to the split initialization of num_chunks.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
49
pngset.c
49
pngset.c
@ -1161,14 +1161,39 @@ png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features)
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
png_set_keep_unknown_chunks(png_structrp png_ptr, int keepIn,
|
||||
png_const_bytep chunk_list, int num_chunksIn)
|
||||
{
|
||||
png_bytep new_list, p;
|
||||
png_byte keep;
|
||||
unsigned int i, num_chunks, old_num_chunks;
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
switch (keepIn)
|
||||
{
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
keep = PNG_HANDLE_CHUNK_AS_DEFAULT;
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
keep = PNG_HANDLE_CHUNK_NEVER;
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
keep = PNG_HANDLE_CHUNK_IF_SAFE;
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||
keep = PNG_HANDLE_CHUNK_ALWAYS;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
|
||||
return;
|
||||
}
|
||||
|
||||
if (num_chunksIn <= 0)
|
||||
{
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
@ -1213,16 +1238,27 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
};
|
||||
|
||||
chunk_list = chunks_to_ignore;
|
||||
num_chunks = (unsigned int)(sizeof chunks_to_ignore)/5;
|
||||
num_chunks = (sizeof chunks_to_ignore)/5;
|
||||
}
|
||||
|
||||
else /* num_chunksIn > 0 */
|
||||
{
|
||||
if (chunk_list == NULL)
|
||||
return;
|
||||
|
||||
if (num_chunksIn > 0)
|
||||
num_chunks = (unsigned int)num_chunksIn;
|
||||
num_chunks = num_chunksIn;
|
||||
}
|
||||
|
||||
old_num_chunks = png_ptr->num_chunk_list;
|
||||
|
||||
/* Since num_chunks is always restricted to UINT_MAX/5 this can't overflow.
|
||||
*/
|
||||
if (num_chunks + old_num_chunks > UINT_MAX/5)
|
||||
{
|
||||
png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
|
||||
return;
|
||||
}
|
||||
|
||||
new_list = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
5 * (num_chunks + old_num_chunks)));
|
||||
|
||||
@ -1233,11 +1269,10 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
png_ptr->chunk_list=NULL;
|
||||
}
|
||||
|
||||
memcpy(new_list + 5*old_num_chunks, chunk_list,
|
||||
5*(unsigned int)num_chunks);
|
||||
memcpy(new_list + 5*old_num_chunks, chunk_list, 5*num_chunks);
|
||||
|
||||
for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5)
|
||||
*p=(png_byte)keep;
|
||||
*p=keep;
|
||||
|
||||
png_ptr->num_chunk_list = old_num_chunks + num_chunks;
|
||||
png_ptr->chunk_list = new_list;
|
||||
|
Loading…
Reference in New Issue
Block a user