Fixed #3714 (segmentation fault of cppcheck checking libtiff)

This commit is contained in:
Daniel Marjamäki 2012-04-14 18:36:19 +02:00
parent 3eede5ba8c
commit c6ba3ba3ca
2 changed files with 6 additions and 1 deletions

View File

@ -731,7 +731,7 @@ void CheckStl::if_find()
if (tok->str() == "if")
tok = tok->next();
for (const Token* const end = tok->link(); tok != end; tok = tok->next()) {
for (const Token* const end = tok->link(); tok != end; tok = (tok == end) ? end : tok->next()) {
if (Token::Match(tok, "&&|(|%oror%"))
tok = tok->next();
else

View File

@ -1234,6 +1234,11 @@ private:
" if (std::find(a,b,c) != c) { }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #3714 - segmentation fault for syntax error
check("void f() {\n"
" if (()) { }\n"
"}");
}
void if_str_find() {