Fix too null pointer dereference (#4810) (#4825)

This commit is contained in:
Adrian Sampson
2024-01-13 20:52:50 -04:00
committed by GitHub
parent 5073f208af
commit 2e999a5441
2 changed files with 7 additions and 4 deletions
+6 -4
View File
@@ -259,10 +259,12 @@ class TraceDeclVisitor final : public VNVisitor {
const std::string name = path.substr(pos == string::npos ? 0 : pos + 1);
// Compute the type of the scope being fixed up
AstNodeModule* const modp = scopep->aboveCellp()->modp();
const VTracePrefixType scopeType = VN_IS(modp, Iface)
? VTracePrefixType::SCOPE_INTERFACE
: VTracePrefixType::SCOPE_MODULE;
const AstCell* const cellp = scopep->aboveCellp();
const VTracePrefixType scopeType = cellp ? (
VN_IS((cellp->modp()), Iface)
? VTracePrefixType::SCOPE_INTERFACE
: VTracePrefixType::SCOPE_MODULE
) : VTracePrefixType::SCOPE_MODULE;
// Push the scope prefix
AstNodeStmt* const pushp = new AstTracePushPrefix{flp, name, scopeType};