[gs-cvs] rev 8039 - trunk/gs/jasper/src/libjasper/base
alexcher at ghostscript.com
alexcher at ghostscript.com
Sat Jun 9 22:21:02 PDT 2007
Author: alexcher
Date: 2007-06-09 22:21:02 -0700 (Sat, 09 Jun 2007)
New Revision: 8039
Modified:
trunk/gs/jasper/src/libjasper/base/jas_malloc.c
Log:
Add a work-around for malloc(0) returning a 0 pointer - call malloc(1)
instead. Bug 688532, customer 870.
DETAILS:
This behavior was observer on IBM 4.3 and 5.1. IEEE 1003.1 spec,
which is aligned with ISO C, states:
If the size of the space requested is 0, the behavior is implementation-defined:
the value returned shall be either a null pointer or a unique pointer.
malloc(0) happens when libjasper reads optional tags in the embedded ICC
profile. This doesn't happen too frequently and we can afford to allocate
a few extra bytes.
DIFFERENCES:
None.
Modified: trunk/gs/jasper/src/libjasper/base/jas_malloc.c
===================================================================
--- trunk/gs/jasper/src/libjasper/base/jas_malloc.c 2007-06-10 05:01:41 UTC (rev 8038)
+++ trunk/gs/jasper/src/libjasper/base/jas_malloc.c 2007-06-10 05:21:02 UTC (rev 8039)
@@ -166,7 +166,8 @@
void *jas_malloc(size_t size)
{
void *p;
-
+ if(size == 0)
+ size = 1;
p = malloc(size);
addMem(p);
return p;
@@ -183,6 +184,8 @@
void *p;
removeMem(ptr);
+ if(size == 0)
+ size = 1;
p = realloc(ptr, size);
addMem(p);
return p;
More information about the gs-cvs
mailing list