Fixed crash on garbage code #7034

This commit is contained in:
PKEuS 2015-10-09 13:49:17 +02:00
parent 7d624f2e21
commit 2eb8492993
2 changed files with 6 additions and 1 deletions

View File

@ -1482,7 +1482,7 @@ void CheckOther::checkCharVariable()
if (astIsSignedChar(index) && index->getValueGE(0x80, _settings)) if (astIsSignedChar(index) && index->getValueGE(0x80, _settings))
charArrayIndexError(tok); charArrayIndexError(tok);
} }
if (Token::Match(tok, "[&|^]") && tok->astOperand2()) { if (Token::Match(tok, "[&|^]") && tok->astOperand2() && tok->astOperand1()) {
bool warn = false; bool warn = false;
if (astIsSignedChar(tok->astOperand1())) { if (astIsSignedChar(tok->astOperand1())) {
const ValueFlow::Value *v1 = tok->astOperand1()->getValueLE(-1, _settings); const ValueFlow::Value *v1 = tok->astOperand1()->getValueLE(-1, _settings);

View File

@ -186,6 +186,7 @@ private:
TEST_CASE(garbageCode134); TEST_CASE(garbageCode134);
TEST_CASE(garbageCode135); // #4994 TEST_CASE(garbageCode135); // #4994
TEST_CASE(garbageCode136); // #7033 TEST_CASE(garbageCode136); // #7033
TEST_CASE(garbageCode137); // #7034
TEST_CASE(garbageValueFlow); TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase); TEST_CASE(garbageSymbolDatabase);
@ -1078,6 +1079,10 @@ private:
checkCode("{ } () { void f() { node_t * n; for (; -n) {} } } { }"); checkCode("{ } () { void f() { node_t * n; for (; -n) {} } } { }");
} }
void garbageCode137() { // #7034
checkCode("\" \" typedef signed char f; \" \"; void a() { f * s = () &[]; (; ) (; ) }");
}
void garbageValueFlow() { void garbageValueFlow() {
// #6089 // #6089