Skip to content

Add null pointer check to fix SEGFAULT#1499

Merged
danmar merged 3 commits into
cppcheck-opensource:masterfrom
knowledge4igor:fix_segfault_in_valueFlowAfterMove
Dec 2, 2018
Merged

Add null pointer check to fix SEGFAULT#1499
danmar merged 3 commits into
cppcheck-opensource:masterfrom
knowledge4igor:fix_segfault_in_valueFlowAfterMove

Conversation

@knowledge4igor
Copy link
Copy Markdown
Contributor

I have got the following SEGFAULT:

0   cppcheck                      	0x0000000103013ddc Token::varId() const + 12 (token.h:576)
1   cppcheck                      	0x0000000103674b58 valueFlowAfterMove(TokenList*, SymbolDatabase*, ErrorLogger*, Settings const*) + 7752 (valueflow.cpp:2963)
2   cppcheck                      	0x0000000103668856 ValueFlow::setValues(TokenList*, SymbolDatabase*, ErrorLogger*, Settings const*) + 358 (valueflow.cpp:4634)
3   cppcheck                      	0x00000001035be2ba Tokenizer::simplifyTokenList2() + 1226 (tokenize.cpp:4062)
4   cppcheck                      	0x00000001032e0bc4 CppCheck::checkFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_istream<char, std::__1::char_traits<char> >&) + 47380 (cppcheck.cpp:423)
5   cppcheck                      	0x00000001032d51d0 CppCheck::check(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 1152 (cppcheck.cpp:83)
6   cppcheck                      	0x0000000102facc3a CppCheckExecutor::check_internal(CppCheck&, int, char const* const*) + 10458 (cppcheckexecutor.cpp:871)
7   cppcheck                      	0x0000000102fa9d86 CppCheckExecutor::check(int, char const* const*) + 502 (cppcheckexecutor.cpp:198)
8   cppcheck                      	0x0000000102f8545f main + 95 (main.cpp:95)
9   libdyld.dylib                 	0x00007fff7da1b015 start + 1

I this PR I'm proposing the fix of this problem.

@orbitcowboy
Copy link
Copy Markdown
Collaborator

Thanks! A test case would be nice!

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Dec 1, 2018

yes the fix looks ok but a test case would be nice.

@knowledge4igor
Copy link
Copy Markdown
Contributor Author

@orbitcowboy @danmar Ok, I will do it in the near future

@knowledge4igor
Copy link
Copy Markdown
Contributor Author

@danmar @orbitcowboy I've added the test case (with TODO), but I'll continue research of this problem to remove TODO from the test case.

@danmar danmar merged commit 61878c5 into cppcheck-opensource:master Dec 2, 2018
@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Dec 2, 2018

ok thanks! I applied these changes. Feel free to open a new PR that fix the TODO

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Dec 2, 2018

For your information I plan to release Cppcheck on december 8th.. so I will not allow improvements much longer..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants