#6771 segmentation fault (invalid code) in SymbolDatabase::SymbolDatabase
This commit is contained in:
parent
d571d5db6f
commit
a5a835b1e0
|
@ -206,7 +206,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
}
|
}
|
||||||
|
|
||||||
// using namespace
|
// using namespace
|
||||||
else if (Token::Match(tok, "using namespace ::| %type% ;|::")) {
|
else if (_tokenizer->isCPP() && Token::Match(tok, "using namespace ::| %type% ;|::")) {
|
||||||
Scope::UsingInfo using_info;
|
Scope::UsingInfo using_info;
|
||||||
|
|
||||||
using_info.start = tok; // save location
|
using_info.start = tok; // save location
|
||||||
|
@ -622,7 +622,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
}
|
}
|
||||||
|
|
||||||
// friend class declaration?
|
// friend class declaration?
|
||||||
else if (Token::Match(tok, "friend class| ::| %any% ;|::")) {
|
else if (_tokenizer->isCPP() && Token::Match(tok, "friend class| ::| %any% ;|::")) {
|
||||||
Type::FriendInfo friendInfo;
|
Type::FriendInfo friendInfo;
|
||||||
|
|
||||||
// save the name start
|
// save the name start
|
||||||
|
@ -644,6 +644,10 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
// fill this in after parsing is complete
|
// fill this in after parsing is complete
|
||||||
friendInfo.type = 0;
|
friendInfo.type = 0;
|
||||||
|
|
||||||
|
if (!scope->definedType) {
|
||||||
|
_tokenizer->syntaxError(tok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
scope->definedType->friendList.push_back(friendInfo);
|
scope->definedType->friendList.push_back(friendInfo);
|
||||||
}
|
}
|
||||||
} else if (scope->type == Scope::eNamespace || scope->type == Scope::eGlobal) {
|
} else if (scope->type == Scope::eNamespace || scope->type == Scope::eGlobal) {
|
||||||
|
|
|
@ -121,6 +121,7 @@ private:
|
||||||
TEST_CASE(garbageCode80);
|
TEST_CASE(garbageCode80);
|
||||||
TEST_CASE(garbageCode81);
|
TEST_CASE(garbageCode81);
|
||||||
TEST_CASE(garbageCode82);
|
TEST_CASE(garbageCode82);
|
||||||
|
TEST_CASE(garbageCode83);
|
||||||
|
|
||||||
TEST_CASE(garbageValueFlow);
|
TEST_CASE(garbageValueFlow);
|
||||||
TEST_CASE(garbageSymbolDatabase);
|
TEST_CASE(garbageSymbolDatabase);
|
||||||
|
@ -671,6 +672,10 @@ private:
|
||||||
ASSERT_THROW(checkCode("p(\"Hello \" 14) _yn(const size_t) typedef bool pfunk (*pfunk)(const size_t)"), InternalError);
|
ASSERT_THROW(checkCode("p(\"Hello \" 14) _yn(const size_t) typedef bool pfunk (*pfunk)(const size_t)"), InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode83() { // #6771
|
||||||
|
ASSERT_THROW(checkCode("namespace A { class } class A { friend C ; } { } ;"), InternalError);
|
||||||
|
}
|
||||||
|
|
||||||
void garbageValueFlow() {
|
void garbageValueFlow() {
|
||||||
// #6089
|
// #6089
|
||||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||||
|
|
Loading…
Reference in New Issue