[gdal-dev] New RFC : RFC 19 - Safer memory allocation in GDAL

Frank Warmerdam warmerdam at pobox.com
Sat Dec 29 20:04:45 EST 2007


Even Rouault wrote:
> Hi all,
> 
> I've written a new RFC (http://trac.osgeo.org/gdal/wiki/rfc19_safememalloc) 
> that is a proposal to avoid under memory allocations due to multiplication 
> overflows.
> 
> This proposal is opened to discussion.

Even,

A bit of preliminary feedback:

  o I'd like to see the CPL prefix used instead of VSI.  VSI is supposed
    to stand for "Virtual Systems Interface" and is intended to wrap lower
    level system stuff, while CPL is used as the prefix for higher level
    convenience stuff.

  o I'd like to see a CPLSafeMalloc2(x,y) and CPLSafeMalloc3(x,y,z) that
    would use the Mult functions, and if an overflow occurs issue an error
    and return NULL.  The caller should be able to just check for a NULL
    result and return if NULL knowing that a CPLError had already been
    issued.  I think this would make use of the 'overflow safe allocation'
    easier (and less verbose) to deploy in many places.

I'm generally supportive of this initiative though it isn't a problem
I've found a great issue myself.

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    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list