Skip to content

Commit

Permalink
Fix #12851 fuzzing crash in Tokenizer::simplifyTypedef() (#6535)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 20, 2024
1 parent 3410d1b commit 9e548af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,10 @@ namespace {
Token::createMutualLinks(tok3->next(), after->previous());
}
}
if (!after) {
mReplaceFailed = true;
return;
}

bool useAfterVarRange = true;
if (Token::simpleMatch(mRangeAfterVar.first, "[")) {
Expand Down Expand Up @@ -1124,7 +1128,9 @@ void Tokenizer::simplifyTypedef()
{
// remove typedefs
for (auto &t: typedefs) {
if (!t.second.replaceFailed()) {
if (t.second.replaceFailed()) {
syntaxError(t.second.getTypedefToken());
} else {
const Token* const typedefToken = t.second.getTypedefToken();
TypedefInfo typedefInfo;
typedefInfo.name = t.second.name();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
typedef q r[];r A

0 comments on commit 9e548af

Please sign in to comment.