Cppcheck reports "Deallocation of an auto-variable results in undefined behaviour" in vcl part

Lubos Lunak l.lunak at collabora.com
Sat Apr 26 13:20:42 PDT 2014


On Saturday 26 of April 2014, julien2412 wrote:
> Hello,
>
> Cppcheck reported this:
> [vcl/source/gdi/bitmap4.cxx:229]: (error) Deallocation of an auto-variable
> results in undefined behaviour
> 137             long            (*pKoeff)[ 256 ] = new long[ 9 ][ 256 ];
> ...
> 229             delete[] pKoeff;
> See
> http://opengrok.libreoffice.org/xref/core/vcl/source/gdi/bitmap4.cxx#137
>
> False positive?

 Yes, it looks bogus.

> Moreover, I searched info about declaring 2D arrays and this notation new
> T[x][y] isn't supposed to work (see
> http://stackoverflow.com/questions/936687/how-do-i-declare-a-2d-array-in-c-
>using-new) Any idea?

 The sizes are constants, there's no such problem.

-- 
 Lubos Lunak
 l.lunak at collabora.com


More information about the LibreOffice mailing list