Fix 9052: Crash: SIGSEGV in Token::previous (this=0x0) while checking mariadb-10.0

This commit is contained in:
Paul Fultz II 2019-03-22 01:56:09 +01:00 committed by Daniel Marjamäki
parent 194631ff9c
commit 91138578cc
2 changed files with 12 additions and 1 deletions

View File

@ -5470,7 +5470,7 @@ void SymbolDatabase::setValueTypeInTokenList()
setValueType(tok, vt);
} else if (tok->str() == "return" && tok->scope()) {
const Function *function = tok->scope()->function;
if (function) {
if (function && function->retDef) {
ValueType vt;
parsedecl(function->retDef, &vt, mDefaultSignedness, mSettings);
setValueType(tok, vt);

View File

@ -481,6 +481,9 @@ private:
TEST_CASE(findGarbageCode);
TEST_CASE(checkEnableIf);
// #9052
TEST_CASE(noCrash1);
// --check-config
TEST_CASE(checkConfiguration);
@ -8783,6 +8786,14 @@ private:
}
void noCrash1() {
ASSERT_NO_THROW(tokenizeAndStringify(
"struct A {\n"
" A( const std::string &name = "" );\n"
"};\n"
"A::A( const std::string &name ) { return; }\n"))
}
void checkConfig(const char code[]) {
errout.str("");