#7050 segmentation fault (invalid code) in isVariableChanged
This commit is contained in:
parent
6cf25825de
commit
8e3e981323
|
@ -924,7 +924,7 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, SymbolDatabase *symbo
|
|||
|
||||
// Variable changed in 3rd for-expression
|
||||
if (Token::simpleMatch(tok2->previous(), "for (")) {
|
||||
if (tok2->astOperand2() && isVariableChanged(tok2->astOperand2()->astOperand2(), tok2->link(), varid)) {
|
||||
if (tok2->astOperand2() && tok2->astOperand2()->astOperand2() && isVariableChanged(tok2->astOperand2()->astOperand2(), tok2->link(), varid)) {
|
||||
varid = 0U;
|
||||
if (settings->debugwarnings)
|
||||
bailout(tokenlist, errorLogger, tok, "variable " + var->name() + " used in loop");
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* Cppcheck - A tool for static C/C++ code analysis
|
||||
* Copyright (C) 2007-2015 Daniel Marjamäki and Cppcheck team.
|
||||
|
@ -191,6 +190,7 @@ private:
|
|||
TEST_CASE(garbageCode139); // #6659
|
||||
TEST_CASE(garbageCode140); // #7035
|
||||
TEST_CASE(garbageCode141); // #7043
|
||||
TEST_CASE(garbageCode142); // #7050
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -1114,6 +1114,10 @@ private:
|
|||
ASSERT_THROW(checkCode("enum { X = << { X } } enum { X = X } = X ;"), InternalError);
|
||||
}
|
||||
|
||||
void garbageCode142() { // #7050
|
||||
checkCode("{ } ( ) { void mapGraphs ( ) { node_t * n ; for (!oid n ) { } } } { }");
|
||||
}
|
||||
|
||||
|
||||
void garbageValueFlow() {
|
||||
// #6089
|
||||
|
|
Loading…
Reference in New Issue