Menu

#271 Realloc leak in hunspell.cxx:337

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 the function get_parser, at the line:

casechars = (char *) realloc(casechars, strlen(casechars) + strlen(wordchars) + 1);

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

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

Discussion