This correctly generates [memleakOnRealloc] int main (void) { char * x = malloc(100UL); x = realloc(x, 10000UL); ... However, when corrected to this: int main (void) { char * x = malloc(100UL); char * tmp = realloc(x, 10000UL); if (NULL == tmp) { free(x); return 1; } x = tmp; ... It incorrectly generates [doubleFree] $ cppcheck --version Cppcheck 1.89 $ uname -a Linux qipk2dyy8 5.2.0-0.bpo.2-amd64 #1 SMP Debian 5.2.9-2~bpo10+1 (2019-08-25) x86_64 GNU/Linux
I have come across this problem that seems like cppcheck just isn't understanding the flow of the if statement. It is showing that memset is getting a -1 value but that else statement should never be accessed for the case when src is > tgt. Obviously this code is a reduced variation of what is actually going on. But it seems to be the smallest piece of code that demonstrates the behavior. #include <stdio.h> #include <string.h> int main (void) { char tgt[7]; char src[7+1] = "7777777"; if (sizeof tgt...
select some text into the unnamed buffer with (yw) visual column highlight a few lines (ctrl-v jjjj) then choose to prepend all lines "I" paste unnamed buffer (ctrl-r ") exit paste mode (ESC) expeted: the yanked word should now prepend each line of the vertical selection. actual: the yanked word prepends only the first line of the selected block If, you use (ctrl-v) perhaps this is an x-ray through to eclipse bindings instead of (ctrl-r ") it works as expected, but you have to do the yank with the...
How about a way to turn that particular message off?
Formatting a prototype I can get the trailing ) to go to new line. int myFunc( int...