#6127 crash on patch(?)-".c" file. Avoid segfault.
This commit is contained in:
parent
65f599bd9e
commit
5a96413220
|
@ -124,8 +124,8 @@ static bool conditionIsTrue(const Token *condition, const std::map<unsigned int,
|
||||||
if (!condition)
|
if (!condition)
|
||||||
return false;
|
return false;
|
||||||
if (condition->str() == "||") {
|
if (condition->str() == "||") {
|
||||||
bool result1 = conditionIsTrue(condition->astOperand1(), programMemory);
|
const bool result1 = conditionIsTrue(condition->astOperand1(), programMemory);
|
||||||
bool result2 = result1 ? true : conditionIsTrue(condition->astOperand2(), programMemory);
|
const bool result2 = result1 ? true : conditionIsTrue(condition->astOperand2(), programMemory);
|
||||||
return result2;
|
return result2;
|
||||||
}
|
}
|
||||||
std::map<unsigned int, MathLib::bigint> progmem(programMemory);
|
std::map<unsigned int, MathLib::bigint> progmem(programMemory);
|
||||||
|
@ -1440,7 +1440,7 @@ static void valueFlowForLoop(TokenList *tokenlist, ErrorLogger *errorLogger, con
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Token * const bodyStart = tok->linkAt(1)->next();
|
Token * const bodyStart = tok->linkAt(1)->next();
|
||||||
if (!bodyStart->link() || bodyStart->str() != "{")
|
if (!bodyStart || !bodyStart->link() || bodyStart->str() != "{")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
unsigned int varid(0);
|
unsigned int varid(0);
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
TEST_CASE(garbageCode7);
|
TEST_CASE(garbageCode7);
|
||||||
TEST_CASE(garbageCode8); // #5511
|
TEST_CASE(garbageCode8); // #5511
|
||||||
TEST_CASE(garbageCode9); // #5604
|
TEST_CASE(garbageCode9); // #5604
|
||||||
|
TEST_CASE(garbageCode10); // #6127
|
||||||
TEST_CASE(simplifyFileAndLineMacro); // tokenize "return - __LINE__;"
|
TEST_CASE(simplifyFileAndLineMacro); // tokenize "return - __LINE__;"
|
||||||
|
|
||||||
TEST_CASE(foreach); // #3690
|
TEST_CASE(foreach); // #3690
|
||||||
|
@ -1115,6 +1115,10 @@ private:
|
||||||
ASSERT_THROW(tokenizeAndStringify("enum { e = { } } ( ) { { enum { } } } { e } ", true), InternalError);
|
ASSERT_THROW(tokenizeAndStringify("enum { e = { } } ( ) { { enum { } } } { e } ", true), InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode10() { // #6127
|
||||||
|
tokenizeAndStringify("for( rl=reslist; rl!=NULL; rl=rl->next )", /*simplify=*/true);
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly
|
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly
|
||||||
ASSERT_EQUALS("\"test.cpp\"", tokenizeAndStringify("__FILE__"));
|
ASSERT_EQUALS("\"test.cpp\"", tokenizeAndStringify("__FILE__"));
|
||||||
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));
|
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));
|
||||||
|
|
Loading…
Reference in New Issue