[PR19351, C++] Fix heap overflow in operator new[]

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Feb 7 11:20:00 GMT 2011


On Mon, Feb 7, 2011 at 5:00 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:

> Btw, I'd really like that C++ people would draft a new entry into libsupc++
> that defers size calculation to the library.

I had long wondered why the C++ standard did  not use an interface a
la calloc().  Oh well.

> Eventually using such
> entry would even be ABI compatible(?) and can address the C++0x requirement
> of raising a different exception.

Note that C++98 also requires a check.  One problem I see is that the standard
requires calling the allocation function (which is a replaceable
function, therefore
user definable) with a very specific semantics constraint on the first argument.
I don't know how you would defer the multiplication and yet remain ABI compliant
when the function is repleacable (and also overloadable at class scope!)

-- Gaby



More information about the Gcc-patches mailing list