Skip to content

Commit

Permalink
Ensure we do not dereference nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
asl committed Feb 23, 2024
1 parent 8fa01e5 commit 94b821f
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ const Node *getSpecificNode(const IR::P4Program *program, cstring name) {

return false;
};
return program->getDeclarations()->where(filter)->singleOrDefault()->template to<Node>();
if (auto *node = program->getDeclarations()->where(filter)->singleOrDefault())
return node->template to<Node>();
return nullptr;
}

template <class T>
Expand Down

0 comments on commit 94b821f

Please sign in to comment.