Imported from libpng-1.2.0beta2.tar
diff --git a/pngmem.c b/pngmem.c
index 19364c3..bff23d7 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation
*
- * libpng 1.2.0beta1 - May 6, 2001
+ * libpng 1.2.0beta2 - May 7, 2001
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -119,7 +119,12 @@
#ifdef PNG_USER_MEM_SUPPORTED
if(png_ptr->malloc_fn != NULL)
- return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+ {
+ ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+ if (ret == NULL)
+ png_error(png_ptr, "Out of memory!");
+ return (ret);
+ }
else
return png_malloc_default(png_ptr, size);
}
@@ -373,15 +378,18 @@
png_voidp PNGAPI
png_malloc(png_structp png_ptr, png_uint_32 size)
{
-#ifndef PNG_USER_MEM_SUPPORTED
png_voidp ret;
-#endif
if (png_ptr == NULL || size == 0)
return ((png_voidp)NULL);
#ifdef PNG_USER_MEM_SUPPORTED
if(png_ptr->malloc_fn != NULL)
- return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+ {
+ ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+ if (ret == NULL)
+ png_error(png_ptr, "Out of Memory!");
+ return (ret);
+ }
else
return (png_malloc_default(png_ptr, size));
}
@@ -407,9 +415,7 @@
#endif
if (ret == NULL)
- {
png_error(png_ptr, "Out of Memory");
- }
return (ret);
}