Skip to content

Commit 41990d3

Browse files
committed
refs #13698 - Library: avoid impossible type lookups
1 parent b81083f commit 41990d3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/library.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,9 @@ const Library::Container* Library::detectContainerInternal(const Token* const ty
13241324
{
13251325
if (!typeStart)
13261326
return nullptr;
1327+
if (typeStart->tokType() != Token::Type::eType && typeStart->tokType() != Token::Type::eName) {
1328+
return nullptr;
1329+
}
13271330
const Token* firstLinkedTok = nullptr;
13281331
for (const Token* tok = typeStart; tok && !tok->varId(); tok = tok->next()) {
13291332
if (!tok->link())
@@ -1889,6 +1892,11 @@ bool Library::isSmartPointer(const Token* tok) const
18891892

18901893
const Library::SmartPointer* Library::detectSmartPointer(const Token* tok, bool withoutStd) const
18911894
{
1895+
if (tok->tokType() != Token::Type::eType && tok->tokType() != Token::Type::eName) {
1896+
return nullptr;
1897+
}
1898+
1899+
// TODO: this is flawed and might result in lookups like "uint64_tflags_"
18921900
std::string typestr = withoutStd ? "std::" : "";
18931901
while (Token::Match(tok, "%name%|::")) {
18941902
typestr += tok->str();

0 commit comments

Comments
 (0)