mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng17] Implemented assert support and usage.
This commit is contained in:
committed by
Glenn Randers-Pehrson
parent
e8e7b6681e
commit
2460d9494d
10
pngmem.c
10
pngmem.c
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
#define PNG_SRC_FILE PNG_SRC_FILE_pngmem
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
/* Free a png_struct */
|
||||
@@ -119,9 +120,7 @@ PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
if (nelements <= 0 || element_size == 0)
|
||||
png_error(png_ptr, "internal error: array alloc");
|
||||
|
||||
assert(nelements > 0 && element_size > 0);
|
||||
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||
}
|
||||
|
||||
@@ -130,9 +129,8 @@ png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
|
||||
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
/* These are internal errors: */
|
||||
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||
(old_array == NULL && old_elements > 0))
|
||||
png_error(png_ptr, "internal error: array realloc");
|
||||
assert(add_elements > 0 && element_size > 0 && old_elements >= 0 &&
|
||||
(old_array != NULL || old_elements == 0));
|
||||
|
||||
/* Check for overflow on the elements count (so the caller does not have to
|
||||
* check.)
|
||||
|
||||
Reference in New Issue
Block a user