[PATCH] [clang/asan] call __asan_poison_cxx_array_cookie after operator new[]

Richard Smith richard at metafoo.co.uk
Thu Sep 25 17:28:50 PDT 2014


On Fri, Sep 19, 2014 at 11:09 AM, Kostya Serebryany <kcc at google.com> wrote:

> Richard,
> When using expr->getOperatorNew()->isReplaceableGlobalAllocationFunction()
> we don't handle operator new defined inside a class (see below).
> Using  expr->getNumPlacementArgs() == 0 fixes that but breaks new
> (std::nothrow) X[n].
>
> Would you suggest another check that will include all non-placement
> operator new cases?
>

(Discussed offline. For posterity:)

Applying this check to class-specific operator new[] doesn't seem correct
in general; the class might in principle track values it has returned from
::operator new[] and provide access to / recycle them by some mechanism
other than calling ::operator delete[].

#include <new>
> #include <stdlib.h>
> class Foo {
>  public:
> #ifdef OPN
>   void *operator new(size_t s);
>   void *operator new[] (size_t s);
> #endif
>   ~Foo();
> };
>
> Foo *getFoo(size_t s) {
>   return new Foo[s];
> }
>
>
>
> On Mon, Aug 25, 2014 at 6:33 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
>
>> LGTM
>>
>> http://reviews.llvm.org/D4774
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140925/99477bd2/attachment.html>


More information about the cfe-commits mailing list