Blob Blame History Raw
diff --git a/libtiff/tif_unix.c b/libtiff/tif_unix.c
index 1387558..0a3a4a8 100644
--- a/libtiff/tif_unix.c
+++ b/libtiff/tif_unix.c
@@ -257,6 +257,8 @@ TIFFOpenW(const wchar_t* name, const char* mode)
 void*
 _TIFFmalloc(tmsize_t s)
 {
+    if ( s == 0 )
+        return ((void *) NULL);
 	return (malloc((size_t) s));
 }
 
diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c
index 2cf1de9..612a00d 100644
--- a/libtiff/tif_win32.c
+++ b/libtiff/tif_win32.c
@@ -329,6 +329,8 @@ TIFFOpenW(const wchar_t* name, const char* mode)
 void*
 _TIFFmalloc(tmsize_t s)
 {
+    if ( s == 0 )
+        return ((tdata_t) NULL);
 	return (malloc((size_t) s));
 }