Skip to content

Commit 1964001

Browse files
Fix #13501 fuzzing crash (heap-use-after-free) in Tokenizer::simplifyNamespaceAliases() (danmar#8101)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 466839e commit 1964001

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/tokenize.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9003,15 +9003,17 @@ void Tokenizer::findGarbageCode() const
90039003
}
90049004
}
90059005
}
9006-
if (cpp && tok->str() == "namespace" && tok->tokAt(-1)) {
9007-
if (!Token::Match(tok->tokAt(-1), ";|{|}|using|inline")) {
9006+
if (cpp && tok->str() == "namespace") {
9007+
if (tok->tokAt(-1) && !Token::Match(tok->tokAt(-1), ";|{|}|using|inline")) {
90089008
if (tok->tokAt(-1)->isUpperCaseName())
90099009
unknownMacroError(tok->tokAt(-1));
90109010
else if (tok->linkAt(-1) && tok->linkAt(-1)->tokAt(-1) && tok->linkAt(-1)->tokAt(-1)->isUpperCaseName())
90119011
unknownMacroError(tok->linkAt(-1)->tokAt(-1));
90129012
else
90139013
syntaxError(tok);
90149014
}
9015+
if (!tok->next() || (Token::Match(tok->next(), "%name% =") && !Token::Match(tok->tokAt(3), "::|%name%")))
9016+
syntaxError(tok);
90159017
}
90169018
if (cpp && tok->str() == "using" && !Token::Match(tok->next(), "::|%name%"))
90179019
syntaxError(tok);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
;namespace b=i;;namespace b={}

0 commit comments

Comments
 (0)