Menu

#272 Realloc leak in hunspell.cxx:1504

v1.0 (example)
open
nobody
leak (2)
5
2015-05-27
2015-05-27
No

Visual Studio code analysis picked this up, a C6308.

In function add, at the line:

dest = (char *) realloc(dest, strlen(dest) + strlen(st) + 1);

...if realloc fails, dest is assigned NULL, and the address of the original allocation is clobbered, thus leaking the memory.

C6308   Realloc leak
1504    'realloc' might return null pointer: assigning null pointer to 'dest', which is passed as an argument to 'realloc', will cause the original memory block to be leaked.

Discussion