Skip to content

Commit aa122ea

Browse files
Fix #12540 #12542 fuzzing crashes (#6177)
1 parent ea60f56 commit aa122ea

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

lib/tokenize.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6268,6 +6268,8 @@ void Tokenizer::removeExtraTemplateKeywords()
62686268
templateName->isTemplate(true);
62696269
templateName = templateName->next();
62706270
}
6271+
if (!templateName)
6272+
syntaxError(tok);
62716273
if (Token::Match(templateName->previous(), "operator %op%|(")) {
62726274
templateName->isTemplate(true);
62736275
if (templateName->str() == "(" && templateName->link())
@@ -8641,7 +8643,7 @@ void Tokenizer::findGarbageCode() const
86418643
syntaxError(tok);
86428644
if (Token::Match(tok, "==|!=|<=|>= %comp%") && tok->strAt(-1) != "operator")
86438645
syntaxError(tok, tok->str() + " " + tok->strAt(1));
8644-
if (Token::simpleMatch(tok, ":: ::"))
8646+
if (Token::simpleMatch(tok, "::") && (!Token::Match(tok->next(), "%name%|*|~") || (tok->next()->isKeyword() && tok->strAt(1) != "operator")))
86458647
syntaxError(tok);
86468648
}
86478649

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
n::template u
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
n i(){t i=0-::-t}

test/testmemleak.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ class TestMemleakInFunction : public TestFixture {
407407
ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", errout_str());
408408

409409
check("void f() {\n"
410-
"void *a = std::nullptr;\n"
410+
"void *a = nullptr;\n"
411411
"a = malloc(10);\n"
412412
"a = realloc(a, 20);\n"
413413
"}");

0 commit comments

Comments
 (0)