Skip to content

Commit ecb9826

Browse files
committed
Add .empty() check in CppServiceHandler::getTags
Fixes segfault
1 parent 84c1447 commit ecb9826

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

plugins/cpp/service/src/cppservice.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,14 +1611,19 @@ CppServiceHandler::getTags(const std::vector<model::CppAstNode>& nodes_)
16111611
tags[node.id].push_back(visibility);
16121612
}
16131613

1614-
//--- Virtual Tag ---//
1614+
//--- Other Tags ---//
16151615

16161616
FuncResult funcNodes = _db->query<cc::model::CppFunction>(
16171617
FuncQuery::entityHash == defNode.entityHash);
1618-
const model::CppFunction& funcNode = *funcNodes.begin();
1618+
if(!funcNodes.empty())
1619+
{
1620+
const model::CppFunction& funcNode = *funcNodes.begin();
16191621

1620-
for (const model::Tag& tag : funcNode.tags)
1621-
tags[node.id].push_back(model::tagToString(tag));
1622+
for (const model::Tag& tag : funcNode.tags)
1623+
tags[node.id].push_back(model::tagToString(tag));
1624+
} else
1625+
LOG(warning) << "Database query result was not expected to be empty. "
1626+
<< __FILE__ << ", line #" << __LINE__;
16221627

16231628
break;
16241629
}

0 commit comments

Comments
 (0)