PHP/mapscript use gdFree instead of free
floerke at DOCTRONIC.DE
Fri Feb 25 04:43:30 EST 2005
Dear mapserver developers,
I had to compile mapserver and php/mapscript on my own (sometimes a painful
task ;^) and found an improvement (or bug or feature) of the php/mapscript
code within php_mapscript.c.
In function "php3_ms_img_saveImage" you use
iptr = (void *)msSaveImageBufferGD(im->img.gd, &size, im->format);
to allocate a pointer to the buffer of the image and use
to free the memory.
My mapscript module crashes while freeing the pointer. I had a look at the
gd documentation and found the follwing hint
The caller must invoke gdFree(), not free(), unless the caller is absolutely
certain that the same implementations of malloc, free, etc. are used both at
library build time and at application build time.
I replaces free(iptr) with gdFree(iptr) and everything works fine. My
bgd.dll appears to use another implementation for malloc/free. Maybe I made
a mistake during the configuration/compilation of php_mapscript.dll, but I
think it's better to use gdFree for safety.
More information about the mapserver-dev