[libpng14] Fix typecast in a png_debug2() statement in png_set_text_2() to

avoid a compiler warning in PNG_DEBUG builds.
Avoid Coverity issues 80855, 80856, and 80857 (PRINTF_ARG_MISMATCH)
in pngtest.c PNG_DEBUG builds.
This commit is contained in:
Glenn Randers-Pehrson 2015-05-09 21:30:18 -05:00
parent fbbd9b7723
commit c1b4f50168
4 changed files with 23 additions and 14 deletions

View File

@ -28,6 +28,10 @@ Other information:
Changes since the last public release (1.4.16): Changes since the last public release (1.4.16):
version 1.4.17beta01 [May 9, 2015] version 1.4.17beta01 [May 9, 2015]
Fix typecast in a png_debug2() statement in png_set_text_2() to
avoid a compiler warning in PNG_DEBUG builds.
Avoid Coverity issues 80855, 80856, and 80857 (PRINTF_ARG_MISMATCH)
in pngtest.c PNG_DEBUG builds.
Send comments/corrections/commendations to glennrp at users.sourceforge.net Send comments/corrections/commendations to glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit or to png-mng-implement at lists.sf.net (subscription required; visit

View File

@ -2952,6 +2952,10 @@ version 1.4.16 [March 19, 2015]
No changes. No changes.
version 1.4.17beta01 [May 9, 2015] version 1.4.17beta01 [May 9, 2015]
Fix typecast in a png_debug2() statement in png_set_text_2() to
avoid a compiler warning in PNG_DEBUG builds.
Avoid Coverity issues 80855, 80856, and 80857 (PRINTF_ARG_MISMATCH)
in pngtest.c PNG_DEBUG builds.
Send comments/corrections/commendations to glennrp at users.sourceforge.net Send comments/corrections/commendations to glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit or to png-mng-implement at lists.sf.net (subscription required; visit

View File

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* Last changed in libpng 1.4.15 [February 12, 2015] * Last changed in libpng 1.4.17 [May 9, 2015]
* Copyright (c) 1998-2015 Glenn Randers-Pehrson * Copyright (c) 1998-2015 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -745,10 +745,10 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
(key_len + text_length + lang_len + lang_key_len + 4)); (key_len + text_length + lang_len + lang_key_len + 4));
if (textp->key == NULL) if (textp->key == NULL)
return(1); return(1);
png_debug2(2, "Allocated %lu bytes at %x in png_set_text", png_debug2(2, "Allocated %lu bytes at %p in png_set_text",
(unsigned long)(png_uint_32) (unsigned long)(png_uint_32)
(key_len + lang_len + lang_key_len + text_length + 4), (key_len + lang_len + lang_key_len + text_length + 4),
(int)textp->key); textp->key);
png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len)); png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
*(textp->key + key_len) = '\0'; *(textp->key + key_len) = '\0';

View File

@ -1,8 +1,8 @@
/* pngtest.c - a simple test program to test libpng /* pngtest.c - a simple test program to test libpng
* *
* Last changed in libpng 1.4.8 [July 7, 2011] * Last changed in libpng 1.4.17 [May 9, 2015]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson * Copyright (c) 1998-2015 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@ -587,7 +587,7 @@ pngtest_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
/* Make sure the caller isn't assuming zeroed memory. */ /* Make sure the caller isn't assuming zeroed memory. */
png_memset(pinfo->pointer, 0xdd, pinfo->size); png_memset(pinfo->pointer, 0xdd, pinfo->size);
if (verbose) if (verbose)
printf("png_malloc %lu bytes at %x\n", (unsigned long)size, printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
pinfo->pointer); pinfo->pointer);
return (png_voidp)(pinfo->pointer); return (png_voidp)(pinfo->pointer);
} }
@ -608,6 +608,7 @@ pngtest_debug_free(png_structp png_ptr, png_voidp ptr)
} }
/* Unlink the element from the list. */ /* Unlink the element from the list. */
if (pinformation != NULL)
{ {
memory_infop FAR *ppinfo = &pinformation; memory_infop FAR *ppinfo = &pinformation;
for (;;) for (;;)
@ -628,7 +629,7 @@ pngtest_debug_free(png_structp png_ptr, png_voidp ptr)
} }
if (pinfo->next == NULL) if (pinfo->next == NULL)
{ {
fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr); fprintf(STDERR, "Pointer %p not found\n", ptr);
break; break;
} }
ppinfo = &pinfo->next; ppinfo = &pinfo->next;
@ -637,7 +638,7 @@ pngtest_debug_free(png_structp png_ptr, png_voidp ptr)
/* Finally free the data. */ /* Finally free the data. */
if (verbose) if (verbose)
printf("Freeing %x\n", ptr); printf("Freeing %p\n", ptr);
png_free_default(png_ptr, ptr); png_free_default(png_ptr, ptr);
ptr = NULL; ptr = NULL;
} }
@ -1242,7 +1243,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
#ifndef SINGLE_ROWBUF_ALLOC #ifndef SINGLE_ROWBUF_ALLOC
pngtest_debug2("Allocating row buffer (pass %d, y = %ld)...", pass, y); pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
row_buf = (png_bytep)png_malloc(read_ptr, row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr)); png_get_rowbytes(read_ptr, read_info_ptr));
pngtest_debug2("0x%08lx (%ld bytes)", (unsigned long)row_buf, pngtest_debug2("0x%08lx (%ld bytes)", (unsigned long)row_buf,
@ -1265,7 +1266,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif /* PNG_WRITE_SUPPORTED */ #endif /* PNG_WRITE_SUPPORTED */
#ifndef SINGLE_ROWBUF_ALLOC #ifndef SINGLE_ROWBUF_ALLOC
pngtest_debug2("Freeing row buffer (pass %d, y = %ld)", pass, y); pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y);
png_free(read_ptr, row_buf); png_free(read_ptr, row_buf);
row_buf = NULL; row_buf = NULL;
#endif /* !SINGLE_ROWBUF_ALLOC */ #endif /* !SINGLE_ROWBUF_ALLOC */
@ -1586,9 +1587,9 @@ main(int argc, char *argv[])
current_allocation); current_allocation);
while (pinfo != NULL) while (pinfo != NULL)
{ {
fprintf(STDERR, " %lu bytes at %x\n", fprintf(STDERR, " %lu bytes at %p\n",
(unsigned long)pinfo->size, (unsigned long)pinfo->size,
(unsigned int) pinfo->pointer); pinfo->pointer);
pinfo = pinfo->next; pinfo = pinfo->next;
} }
} }
@ -1663,8 +1664,8 @@ main(int argc, char *argv[])
current_allocation); current_allocation);
while (pinfo != NULL) while (pinfo != NULL)
{ {
fprintf(STDERR, " %lu bytes at %x\n", fprintf(STDERR, " %lu bytes at %p\n",
(unsigned long)pinfo->size, (unsigned int)pinfo->pointer); (unsigned long)pinfo->size, pinfo->pointer);
pinfo = pinfo->next; pinfo = pinfo->next;
} }
} }