Fix issue 9667: crash: crash in valueflow for weird code where label address is returned (#2602)

This commit is contained in:
Paul Fultz II 2020-04-11 06:56:53 -05:00 committed by GitHub
parent e8e3c2660d
commit 8b27f1c216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -34,7 +34,7 @@ struct ForwardTraversal {
if (out)
*out = tok->link();
return Progress::Skip;
} else if (Token::Match(tok, "?|&&|%oror%")) {
} else if (Token::Match(tok, "?|&&|%oror%") && tok->astOperand1() && tok->astOperand2()) {
if (traverseConditional(tok, f, traverseUnknown) == Progress::Break)
return Progress::Break;
if (out)

View File

@ -4488,6 +4488,16 @@ private:
" };\n"
"}\n";
valueOfTok(code, "x");
code = "void *foo(void *x);\n"
"void *foo(void *x)\n"
"{\n"
" if (!x)\n"
"yes:\n"
" return &&yes;\n"
" return x;\n"
"}\n";
valueOfTok(code, "x");
}
void valueFlowHang() {