[mapserver-dev] Ticket 3559 - malloc/calloc/realloc return values should always be checked

Frank Warmerdam warmerdam at pobox.com
Fri Oct 8 10:12:58 EDT 2010

strk wrote:
> On: Thursday, October 07, 2010 9:42 AM, Frank Warmerdam wrote:
>> I would like to propose an msSmallAlloc() function that behaves in a similar
>> fashion, just writing an error to stderr in case of failure and calling
>> exit().  Likewise, an msStrdup() with similar behavior.
> Better than nothing, but this will fail to be catchable by 
> mapscript or the CGI (think XML or in-image exception). 
> It's very frustrating when you get a blank image and have
> to resort to forcing text/html content type or even worst
> reading server logs, and there are already lots of such cases.


Well, I can assure you that in the situation where msSmallAlloc()
fails there would be no way of actually preparing an error report
and burning it into an image for "inimage" error reports.  Things
are already too desperate.

It is in fact very doubtful that we could even allocate a new
errorObj for the error stack if we called msSetError().

To put all this in context, GDAL/OGR has always "just died" with an
error message to stderr if small allocations fail, including when run
in the context of applications like ArcGIS.  This has never yet, as
far as I recall, been reported as a problem.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the mapserver-dev mailing list