#6733 segmentation fault (invalid code) in Tokenizer::simplifyAddBracesPair
Avoid access to NULL-token by throwing an InternalError
This commit is contained in:
parent
6857dbe864
commit
b81e82d462
|
@ -4503,7 +4503,10 @@ Token *Tokenizer::simplifyAddBracesPair(Token *tok, bool commandWithCondition)
|
|||
tokAfterCondition->previous()->insertToken("{");
|
||||
Token * tokOpenBrace = tokAfterCondition->previous();
|
||||
Token * tokEnd = tokAfterCondition->linkAt(1)->linkAt(2)->linkAt(1);
|
||||
|
||||
if (!tokEnd) {
|
||||
syntaxError(tokAfterCondition);
|
||||
return nullptr;
|
||||
}
|
||||
tokEnd->insertToken("}");
|
||||
Token * tokCloseBrace = tokEnd->next();
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ private:
|
|||
TEST_CASE(garbageCode54); // #6722
|
||||
TEST_CASE(garbageCode55); // #6724
|
||||
TEST_CASE(garbageCode56); // #6713
|
||||
TEST_CASE(garbageCode57); // #6733
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -540,6 +541,10 @@ private:
|
|||
checkCode("void foo() { int a = 0; int b = ???; }");
|
||||
}
|
||||
|
||||
void garbageCode57() { // #6731
|
||||
ASSERT_THROW(checkCode("{ } if () try { } catch (...) B::~B { }"), InternalError);
|
||||
}
|
||||
|
||||
void garbageValueFlow() {
|
||||
// #6089
|
||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||
|
|
Loading…
Reference in New Issue