[libpng16] Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
pngset.c to avoid warnings about dead code.
diff --git a/pngset.c b/pngset.c
index 5aaed94..5740730 100644
--- a/pngset.c
+++ b/pngset.c
@@ -2,7 +2,7 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -190,6 +190,7 @@
if (info_ptr->hist == NULL)
{
png_warning(png_ptr, "Insufficient memory for hIST chunk data");
+
return;
}
@@ -271,7 +272,7 @@
png_debug1(1, "in %s storage function", "pCAL");
if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL
- || (nparams > 0 && params == NULL))
+ || (nparams > 0 && params == NULL))
return;
length = strlen(purpose) + 1;
@@ -301,6 +302,7 @@
if (info_ptr->pcal_purpose == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL purpose");
+
return;
}
@@ -322,6 +324,7 @@
if (info_ptr->pcal_units == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL units");
+
return;
}
@@ -333,6 +336,7 @@
if (info_ptr->pcal_params == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL params");
+
return;
}
@@ -349,6 +353,7 @@
if (info_ptr->pcal_params[i] == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL parameter");
+
return;
}
@@ -398,6 +403,7 @@
if (info_ptr->scal_s_width == NULL)
{
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
+
return;
}
@@ -416,6 +422,7 @@
info_ptr->scal_s_width = NULL;
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
+
return;
}
@@ -519,6 +526,7 @@
else
{
png_warning(png_ptr, "Invalid palette length");
+
return;
}
}
@@ -531,7 +539,6 @@
))
{
png_error(png_ptr, "Invalid palette");
- return;
}
/* It may not actually be necessary to set png_ptr->palette here;
@@ -655,6 +662,7 @@
if (new_iccp_name == NULL)
{
png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk");
+
return;
}
@@ -668,6 +676,7 @@
new_iccp_name = NULL;
png_benign_error(png_ptr,
"Insufficient memory to process iCCP profile");
+
return;
}
@@ -743,6 +752,7 @@
{
png_chunk_report(png_ptr, "too many text chunks",
PNG_CHUNK_WRITE_ERROR);
+
return 1;
}
@@ -798,7 +808,7 @@
else
lang_key_len = 0;
}
-# else /* PNG_iTXt_SUPPORTED */
+# else /* iTXt */
{
png_chunk_report(png_ptr, "iTXt chunk not supported",
PNG_CHUNK_WRITE_ERROR);
@@ -831,6 +841,7 @@
{
png_chunk_report(png_ptr, "text chunk: out of memory",
PNG_CHUNK_WRITE_ERROR);
+
return 1;
}
@@ -904,6 +915,7 @@
mod_time->second > 60)
{
png_warning(png_ptr, "Ignoring invalid time value");
+
return;
}
@@ -920,6 +932,7 @@
png_debug1(1, "in %s storage function", "tRNS");
if (png_ptr == NULL || info_ptr == NULL)
+
return;
if (trans_alpha != NULL)
@@ -945,9 +958,10 @@
if (trans_color != NULL)
{
+#ifdef PNG_WARNINGS_SUPPORTED
if (info_ptr->bit_depth < 16)
{
- unsigned int sample_max = (1U << info_ptr->bit_depth) - 1U;
+ int sample_max = (1 << info_ptr->bit_depth) - 1;
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
trans_color->gray > sample_max) ||
@@ -955,14 +969,15 @@
(trans_color->red > sample_max ||
trans_color->green > sample_max ||
trans_color->blue > sample_max)))
- png_warning(png_ptr,
- "tRNS chunk has out-of-range samples for bit_depth");
+ png_warning(png_ptr,
+ "tRNS chunk has out-of-range samples for bit_depth");
}
+#endif
+
+ info_ptr->trans_color = *trans_color;
if (num_trans == 0)
num_trans = 1;
-
- info_ptr->trans_color = *trans_color;
}
info_ptr->num_trans = (png_uint_16)num_trans;
@@ -1004,6 +1019,7 @@
{
/* Out of memory or too many chunks */
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
+
return;
}
@@ -1119,7 +1135,7 @@
png_unknown_chunkp np;
if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||
- unknowns == NULL)
+ unknowns == NULL)
return;
/* Check for the failure cases where support has been disabled at compile
@@ -1133,6 +1149,7 @@
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
{
png_app_error(png_ptr, "no unknown chunk support on read");
+
return;
}
# endif
@@ -1141,6 +1158,7 @@
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
{
png_app_error(png_ptr, "no unknown chunk support on write");
+
return;
}
# endif
@@ -1158,6 +1176,7 @@
{
png_chunk_report(png_ptr, "too many unknown chunks",
PNG_CHUNK_WRITE_ERROR);
+
return;
}
@@ -1267,6 +1286,7 @@
if (memcmp(list, add, 4) == 0)
{
list[4] = (png_byte)keep;
+
return count;
}
}
@@ -1294,6 +1314,7 @@
if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
{
png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
+
return;
}
@@ -1343,6 +1364,7 @@
* which can be switched off.
*/
png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list");
+
return;
}
@@ -1358,6 +1380,7 @@
if (num_chunks + old_num_chunks > UINT_MAX/5)
{
png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
+
return;
}
@@ -1495,23 +1518,27 @@
{
png_warning(png_ptr,
"Compression buffer size cannot be changed because it is in use");
+
return;
}
+#ifndef __COVERITY__
if (size > ZLIB_IO_MAX)
{
png_warning(png_ptr,
"Compression buffer size limited to system maximum");
size = ZLIB_IO_MAX; /* must fit */
}
+#endif
- else if (size < 6)
+ if (size < 6)
{
/* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
* if this is permitted.
*/
png_warning(png_ptr,
"Compression buffer size cannot be reduced below 6");
+
return;
}
@@ -1553,8 +1580,8 @@
void PNGAPI
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
{
- if (png_ptr != NULL)
- png_ptr->user_chunk_cache_max = user_chunk_cache_max;
+ if (png_ptr != NULL)
+ png_ptr->user_chunk_cache_max = user_chunk_cache_max;
}
/* This function was added to libpng 1.4.1 */