#6712 segmentation fault (invalid code) in CheckExceptionSafety::checkRethrowCopy. Local fix to avoid accessing NULL-token
This commit is contained in:
parent
133d8f9a91
commit
8adff0a31b
|
@ -155,9 +155,11 @@ void CheckExceptionSafety::checkRethrowCopy()
|
|||
const unsigned int varid = i->classStart->tokAt(-2)->varId();
|
||||
if (varid) {
|
||||
for (const Token* tok = i->classStart->next(); tok && tok != i->classEnd; tok = tok->next()) {
|
||||
if (Token::simpleMatch(tok, "catch (") && tok->next()->link() && tok->next()->link()->next()) // Don't check inner catch - it is handled in another iteration of outer loop.
|
||||
if (Token::simpleMatch(tok, "catch (") && tok->next()->link() && tok->next()->link()->next()) { // Don't check inner catch - it is handled in another iteration of outer loop.
|
||||
tok = tok->next()->link()->next()->link();
|
||||
else if (Token::Match(tok, "throw %varid% ;", varid))
|
||||
if (!tok)
|
||||
break;
|
||||
} else if (Token::Match(tok, "throw %varid% ;", varid))
|
||||
rethrowCopyError(tok, tok->strAt(1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ private:
|
|||
TEST_CASE(garbageCode45); // #6608
|
||||
TEST_CASE(garbageCode46); // #6705
|
||||
TEST_CASE(garbageCode47); // #6706
|
||||
TEST_CASE(garbageCode48); // #6712
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -495,6 +496,10 @@ private:
|
|||
checkCode(" { { }; }; * new private: B: B;");
|
||||
}
|
||||
|
||||
void garbageCode48() { // #6712
|
||||
checkCode(" { d\n\" ) d ...\n\" } int main ( ) { ( ) catch ( A a ) { { } catch ( ) \"\" } }");
|
||||
}
|
||||
|
||||
void garbageValueFlow() {
|
||||
// #6089
|
||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||
|
|
Loading…
Reference in New Issue