diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e529366f40c..113d68e8b66 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8766,6 +8766,8 @@ void Tokenizer::findGarbageCode() const // Garbage templates.. if (isCPP()) { for (const Token *tok = tokens(); tok; tok = tok->next()) { + if (Token::simpleMatch(tok, "< >") && !(Token::Match(tok->tokAt(-1), "%name%") || (tok->tokAt(-1) && Token::Match(tok->tokAt(-2), "operator %op%")))) + syntaxError(tok); if (!Token::simpleMatch(tok, "template <")) continue; if (tok->previous() && !Token::Match(tok->previous(), ":|;|{|}|)|>|\"C++\"")) { diff --git a/test/cli/fuzz-crash/crash-adb20a108c3686d79bc9bd0e4025445e3a35fa49.crdownload b/test/cli/fuzz-crash/crash-adb20a108c3686d79bc9bd0e4025445e3a35fa49.crdownload new file mode 100644 index 00000000000..98e8746abd0 --- /dev/null +++ b/test/cli/fuzz-crash/crash-adb20a108c3686d79bc9bd0e4025445e3a35fa49.crdownload @@ -0,0 +1 @@ +template<#p<>tu< <>tu=e \ No newline at end of file