diff options
Diffstat (limited to 'Build/source/libs/libpng/pngmem.c')
-rw-r--r-- | Build/source/libs/libpng/pngmem.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Build/source/libs/libpng/pngmem.c b/Build/source/libs/libpng/pngmem.c index f1cb69395e6..248060f3817 100644 --- a/Build/source/libs/libpng/pngmem.c +++ b/Build/source/libs/libpng/pngmem.c @@ -1,9 +1,9 @@ /* pngmem.c - stub functions for memory allocation * - * libpng version 1.2.8 - December 3, 2004 + * Last changed in libpng 1.2.13 November 13, 2006 * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2004 Glenn Randers-Pehrson + * Copyright (c) 1998-2006 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.) * @@ -17,6 +17,8 @@ #define PNG_INTERNAL #include "png.h" +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + /* Borland DOS special memory handler */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) /* if you change this, be sure to change the one in png.h also */ @@ -135,6 +137,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ + if (png_ptr == NULL || size == 0) + return (NULL); + #ifdef PNG_MAX_MALLOC_64K if (size > (png_uint_32)65536L) { @@ -288,6 +293,8 @@ png_free_default(png_structp png_ptr, png_voidp ptr) { #endif /* PNG_USER_MEM_SUPPORTED */ + if(png_ptr == NULL) return; + if (png_ptr->offset_table != NULL) { int i; @@ -534,8 +541,10 @@ png_voidp PNGAPI png_malloc_warn(png_structp png_ptr, png_uint_32 size) { png_voidp ptr; - png_uint_32 save_flags=png_ptr->flags; + png_uint_32 save_flags; + if(png_ptr == NULL) return (NULL); + save_flags=png_ptr->flags; png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); png_ptr->flags=save_flags; @@ -578,9 +587,11 @@ void PNGAPI png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { + if(png_ptr != NULL) { png_ptr->mem_ptr = mem_ptr; png_ptr->malloc_fn = malloc_fn; png_ptr->free_fn = free_fn; + } } /* This function returns a pointer to the mem_ptr associated with the user @@ -590,6 +601,8 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr png_voidp PNGAPI png_get_mem_ptr(png_structp png_ptr) { + if(png_ptr == NULL) return (NULL); return ((png_voidp)png_ptr->mem_ptr); } #endif /* PNG_USER_MEM_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |