From a5e24569a6eae5b13184ea50edfbbfb75b38dbad Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 15 Jun 2024 17:36:54 +0200 Subject: [PATCH] Fix #12803 fuzzing crash in Tokenizer::setVarIdPass2() (#6530) --- lib/tokenize.cpp | 2 ++ .../fuzz-crash_c/crash-7af21bec1d9be105742fdcb336514aae26ab4425 | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 test/cli/fuzz-crash_c/crash-7af21bec1d9be105742fdcb336514aae26ab4425 diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 195924e7191..bc5d1c7443f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5107,6 +5107,8 @@ void Tokenizer::setVarIdPass2() classnameTokens.push_back(tokStart->next()); tokStart = tokStart->tokAt(2); } + if (!tokStart) + syntaxError(tok); } std::string classname; diff --git a/test/cli/fuzz-crash_c/crash-7af21bec1d9be105742fdcb336514aae26ab4425 b/test/cli/fuzz-crash_c/crash-7af21bec1d9be105742fdcb336514aae26ab4425 new file mode 100644 index 00000000000..6620c0d315f --- /dev/null +++ b/test/cli/fuzz-crash_c/crash-7af21bec1d9be105742fdcb336514aae26ab4425 @@ -0,0 +1,2 @@ +i +class q::_ \ No newline at end of file