From 7700cff0e91b504056f1808fddb898562ca9a6e6 Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Sat, 30 Jan 2021 00:33:09 -0500 Subject: [PATCH] fix daca crash in openfst fst_test.cc (#3095) --- lib/symboldatabase.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a45e522fa..f0fee1fe6 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5099,16 +5099,21 @@ const Function* SymbolDatabase::findFunction(const Token *tok) const } if (currScope) { - while (currScope && !(Token::Match(tok1, "%type% :: %name% [(),>]") || - (Token::Match(tok1, "%type% <") && Token::Match(tok1->linkAt(1), "> :: %name% (")))) { + while (currScope && tok1 && !(Token::Match(tok1, "%type% :: %name% [(),>]") || + (Token::Match(tok1, "%type% <") && Token::Match(tok1->linkAt(1), "> :: %name% (")))) { if (tok1->strAt(1) == "::") tok1 = tok1->tokAt(2); - else + else if (tok1->strAt(1) == "<") tok1 = tok1->linkAt(1)->tokAt(2); - currScope = currScope->findRecordInNestedList(tok1->str()); + else + tok1 = nullptr; + + if (tok1) + currScope = currScope->findRecordInNestedList(tok1->str()); } - tok1 = tok1->tokAt(2); + if (tok1) + tok1 = tok1->tokAt(2); if (currScope && tok1) return currScope->findFunction(tok1);