Opened 19 years ago

Closed 19 years ago

#1257 closed defect (fixed)

use gdFree instead of free

Reported by: floerke@… Owned by: mapserverbugs
Priority: high Milestone:
Component: MapScript-PHP Version: unspecified
Severity: normal Keywords:
Cc:

Description

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
  free(iptr);
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.

Change History (2)

comment:1 by dmorissette, 19 years ago

Status: newassigned
Looking into this now.

comment:2 by dmorissette, 19 years ago

Resolution: fixed
Status: assignedclosed
Fixed in both 4.5 and 4.4 branches (will be in 4.4.2).
Note: See TracTickets for help on using tickets.