Skip to content

Commit

Permalink
Fix #11638 Crash Library::getFunctionName: SIGSEGV (#6268)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Apr 10, 2024
1 parent 24889eb commit 83d4e31
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8415,6 +8415,9 @@ void Tokenizer::findGarbageCode() const
else if (Token::Match(tok, "[({<] %assign%"))
syntaxError(tok);

else if (Token::Match(tok, "[`\\@]"))
syntaxError(tok);

// UNKNOWN_MACRO(return)
if (tok->isKeyword() && Token::Match(tok, "throw|return )") && Token::Match(tok->linkAt(1)->previous(), "%name% ("))
unknownMacroError(tok->linkAt(1)->previous());
Expand Down
6 changes: 6 additions & 0 deletions test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class TestGarbage : public TestFixture {
TEST_CASE(garbageCode223); // #11639
TEST_CASE(garbageCode224);
TEST_CASE(garbageCode225);
TEST_CASE(garbageCode226);

TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1

Expand Down Expand Up @@ -1740,6 +1741,11 @@ class TestGarbage : public TestFixture {
ASSERT_THROW_INTERNAL(checkCode("int n() { c * s0, 0 s0 = c(sizeof = ) }"), SYNTAX);
ASSERT_THROW_INTERNAL(checkCode("int n() { c * s0, 0 s0 = c(sizeof |= ) }"), SYNTAX);
}
void garbageCode226() {
ASSERT_THROW_INTERNAL(checkCode("int a() { (b((c)`)) } {}"), SYNTAX); // #11638
ASSERT_THROW_INTERNAL(checkCode("int a() { (b((c)\\)) } {}"), SYNTAX);
ASSERT_THROW_INTERNAL(checkCode("int a() { (b((c)@)) } {}"), SYNTAX);
}

void syntaxErrorFirstToken() {
ASSERT_THROW_INTERNAL(checkCode("&operator(){[]};"), SYNTAX); // #7818
Expand Down
2 changes: 1 addition & 1 deletion test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4386,7 +4386,7 @@ class TestOther : public TestFixture {
ASSERT_EQUALS("", errout_str());

// Ticket #6132 "crash: daca: kvirc CheckOther::checkRedundantAssignment()"
check("void HttpFileTransfer :: transferTerminated ( bool bSuccess@1 ) {\n"
check("void HttpFileTransfer :: transferTerminated ( bool bSuccess ) {\n"
"if ( m_szCompletionCallback . isNull ( ) ) {\n"
"KVS_TRIGGER_EVENT ( KviEvent_OnHTTPGetTerminated , out ? out : ( g_pApp . activeConsole ( ) ) , & vParams )\n"
"} else {\n"
Expand Down

0 comments on commit 83d4e31

Please sign in to comment.