Today I found a very severe bug in our code where an uninitialized pointer was dereferenced. cppcheck (1.69) did not report the issue. After several tries I managed to reproduce it in a smaller environment:
int do_something()
{
int* p;
do
{
if (true)
{
}
else
{
return 1;
}
*p = 7;
p = new int(9);
} while (*p != 8);
return 0;
}
int main(int argc, char* argv[])
{
return 0;
}
cppcheck's only output is "Memory leak: p" whereas dereferencing the uninitialized pointer is not mentioned.
This is a minimal example, in the sense that if I remove one of the following, the error is indeed detected:
p = new int(9);
the if statement
The loop (i.e. keep just the body without the loop)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Today I found a very severe bug in our code where an uninitialized pointer was dereferenced. cppcheck (1.69) did not report the issue. After several tries I managed to reproduce it in a smaller environment:
cppcheck's only output is "Memory leak: p" whereas dereferencing the uninitialized pointer is not mentioned.
This is a minimal example, in the sense that if I remove one of the following, the error is indeed detected:
yes that should be reported. can you please report this to the issue tracker http://trac.cppcheck.net/ so we don't forget this.
I wanted to by my trac acount is not verified. I didn't get the mail verification e-mail.
ok sorry for the trouble. Sometimes the verification email does not work. I don't know why.
Your verification code is 41mbnTVv
please try to login. you should be asked for the verification code. and then it should work..
Opened the ticket. Thanks a lot!