[ODE] Small memory bug in gimpact

Daniel K. O. danielko.listas at gmail.com
Tue Nov 20 00:37:52 MST 2007


Chunky Kibbles escreveu:
> Heya, I'm fairly certain this qualifies as a bug in gimpact.
> 
> In gim_memory.cpp [in ODE 0.9], lines118-129:
> void * gim_alloc(size_t size)
> {
> 	void * ptr = 0;
> 	ptr = malloc(size);
> 	/*if (g_allocfn) ptr = g_allocfn(size); else ptr = * malloc(size);//_mm_malloc(size,0);*/
> 	if(ptr==0)
> 	{
> 		float * fp = 0;
> 		*fp = 0.0f;
> 	}
> 	return ptr;
> }
> 
> That *fp=0.0f is always assigning a value to the memory pointed to by
> a a null pointer, which throws an exception here.

That looks more like a poor man's assert(). I would prefer a SIGABRT +
some descriptive message in stderr ("out of memory") than a SIGSEGV.


-- 
Daniel K. O.
"The only way to succeed is to build success yourself"


More information about the ODE mailing list