From 26849f4693bd508bc14c777a0e6ce09e9ed8de6c Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Fri, 10 Aug 2012 16:01:45 -0500 Subject: [PATCH] [libpng16] Consistently use png_memset(), png_memcpy(), and png_memcmp(), except in pngtest.c and example.c where these macros are not visible. --- ANNOUNCE | 2 ++ CHANGES | 2 ++ pngmem.c | 2 +- pngread.c | 4 ++-- pngrutil.c | 4 ++-- pngwrite.c | 4 ++-- pngwutil.c | 8 ++++---- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 49e743c6e..cbf54be01 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -431,6 +431,8 @@ Version 1.6.0beta27 [August 10, 2012] and cause it not to fail at the comparison step if libpng lacks support for writing chunks that it reads from the input (currently only implemented for compressed text chunks). + Consistently use png_memset(), png_memcpy(), and png_memcmp(), except in + pngtest.c and example.c where these macros are not visible. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index f1c5b7df8..2f9129518 100644 --- a/CHANGES +++ b/CHANGES @@ -4182,6 +4182,8 @@ Version 1.6.0beta27 [August 10, 2012] and cause it not to fail at the comparison step if libpng lacks support for writing chunks that it reads from the input (currently only implemented for compressed text chunks). + Consistently use png_memset(), png_memcpy(), and png_memcmp(), except in + pngtest.c and example.c where these macros are not visible. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngmem.c b/pngmem.c index bc88dbf1f..0fe34e7a0 100644 --- a/pngmem.c +++ b/pngmem.c @@ -30,7 +30,7 @@ png_destroy_png_struct(png_structrp png_ptr) * png_get_mem_ptr, so fake a temporary png_struct to support this. */ png_struct dummy_struct = *png_ptr; - memset(png_ptr, 0, (sizeof *png_ptr)); + png_memset(png_ptr, 0, (sizeof *png_ptr)); png_free(&dummy_struct, png_ptr); # ifdef PNG_SETJMP_SUPPORTED diff --git a/pngread.c b/pngread.c index b2580c6c4..3af2224f8 100644 --- a/pngread.c +++ b/pngread.c @@ -1169,7 +1169,7 @@ png_image_read_init(png_imagep image) /* And set the rest of the structure to NULL to ensure that the various * fields are consistent. */ - memset(image, 0, (sizeof *image)); + png_memset(image, 0, (sizeof *image)); image->version = PNG_IMAGE_VERSION; if (png_ptr != NULL) @@ -2527,7 +2527,7 @@ png_image_read_colormap(png_voidp argument) * PNG_CMAP_RGB algorithm will use. If the two entries don't * match, add the new one and set this as the background index. */ - if (memcmp((png_const_bytep)display->colormap + + if (png_memcmp((png_const_bytep)display->colormap + sample_size * cmap_entries, (png_const_bytep)display->colormap + sample_size * PNG_RGB_INDEX(r,g,b), diff --git a/pngrutil.c b/pngrutil.c index 771facf48..2caa91459 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1438,7 +1438,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (profile != NULL) { - memcpy(profile, profile_header, + png_memcpy(profile, profile_header, (sizeof profile_header)); size = 12 * tag_count; @@ -1508,7 +1508,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) keyword_length+1)); if (info_ptr->iccp_name != NULL) { - memcpy(info_ptr->iccp_name, keyword, + png_memcpy(info_ptr->iccp_name, keyword, keyword_length+1); info_ptr->iccp_proflen = profile_length; diff --git a/pngwrite.c b/pngwrite.c index f7b0f5c50..0389d8502 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1907,8 +1907,8 @@ png_image_set_PLTE(png_image_write_control *display) png_color palette[256]; png_byte tRNS[256]; - memset(tRNS, 255, (sizeof tRNS)); - memset(palette, 0, (sizeof palette)); + png_memset(tRNS, 255, (sizeof tRNS)); + png_memset(palette, 0, (sizeof palette)); for (i=num_trans=0; izstream.msg); @@ -1731,9 +1731,9 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, * TODO: validate the language tag correctly (see the spec.) */ if (lang == NULL) lang = ""; /* empty language is valid */ - lang_len = strlen(lang)+1; + lang_len = png_strlen(lang)+1; if (lang_key == NULL) lang_key = ""; /* may be empty */ - lang_key_len = strlen(lang_key)+1; + lang_key_len = png_strlen(lang_key)+1; if (text == NULL) text = ""; /* may be empty */ prefix_len = key_len; @@ -1747,7 +1747,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, else prefix_len = (png_uint_32)(prefix_len + lang_key_len); - png_text_compress_init(&comp, (png_const_bytep)text, strlen(text)); + png_text_compress_init(&comp, (png_const_bytep)text, png_strlen(text)); if (compression) { -- GitLab