Fix crash on nullptr deref (#4189)
This commit is contained in:
parent
a76ba698c2
commit
90392faa2b
|
@ -2270,7 +2270,7 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token * tok)
|
||||||
if (!function)
|
if (!function)
|
||||||
return {};
|
return {};
|
||||||
return { function->retDef, function->returnDefEnd() };
|
return { function->retDef, function->returnDefEnd() };
|
||||||
} else if (tok->previous()->function()) {
|
} else if (tok->previous() && tok->previous()->function()) {
|
||||||
const Function *function = tok->previous()->function();
|
const Function *function = tok->previous()->function();
|
||||||
return {function->retDef, function->returnDefEnd()};
|
return {function->retDef, function->returnDefEnd()};
|
||||||
} else if (Token::simpleMatch(tok, "=")) {
|
} else if (Token::simpleMatch(tok, "=")) {
|
||||||
|
|
|
@ -4816,11 +4816,17 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void symboldatabase92() { // daca crash
|
void symboldatabase92() { // daca crash
|
||||||
GET_SYMBOL_DB("template <size_t, typename...> struct a;\n"
|
{
|
||||||
"template <size_t b, typename c, typename... d>\n"
|
GET_SYMBOL_DB("template <size_t, typename...> struct a;\n"
|
||||||
"struct a<b, c, d...> : a<1, d...> {};\n"
|
"template <size_t b, typename c, typename... d>\n"
|
||||||
"template <typename... e> struct f : a<0, e...> {};");
|
"struct a<b, c, d...> : a<1, d...> {};\n"
|
||||||
ASSERT_EQUALS("", errout.str());
|
"template <typename... e> struct f : a<0, e...> {};");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
GET_SYMBOL_DB("b.f();");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void symboldatabase93() { // alignas attribute
|
void symboldatabase93() { // alignas attribute
|
||||||
|
|
Loading…
Reference in New Issue