[Dcmlib] [Fwd: BUG in jas_malloc (aka seg fault with bcc32)]

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Jul 6 01:44:48 CEST 2005


Hello,

	Ok took me a while to understand what was going on (especially since I 
don't have a debugger for bcc32...). Jasper simply does not support 
compiler like borland that return NULL on a malloc(0)...

	Anyway I have added a small hack that add support for bcc32.

All borland users are welcome to test the code,
Mathieu

-------- Original Message --------
Subject: BUG in jas_malloc (aka seg fault with bcc32)
Date: Tue, 05 Jul 2005 18:49:17 -0400
From: Mathieu Malaterre <mmalater at nycap.rr.com>
To: jasper-discussion at yahoogroups.com

Hello,

	I found a bug in jasper. The function jas_malloc returns

void *jas_malloc(size_t size)
{
   return malloc(size);
}

	But most of the time the code test is the return value is different
from NULL. However as specified :

http://www.opengroup.org/onlinepubs/007908799/xsh/malloc.html

	This is perfectly legal to return NULL, when size of object is zero
(which seems to happen at least in a few images I am trying to read). As
a proof of concept one can change the malloc function to:

void *jas_malloc(size_t size)
{
   return malloc(size+1);
}
	At least this produce the proper result (solve the seg fault happen
with borland compiler).


	Is there any reason why this case was not taken into account ?

Thanks,
Mathieu




More information about the Dcmlib mailing list