Internals: Resolve potential SEGV risk (#3350)

This commit is contained in:
Yutetsu TAKATSUKASA 2022-03-13 18:13:51 +09:00 committed by GitHub
parent e744c21f56
commit 47226236f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -167,16 +167,14 @@ private:
nodep->v3warn(E_UNSUPPORTED, "Unsupported: Only one PSL clock allowed per assertion"); nodep->v3warn(E_UNSUPPORTED, "Unsupported: Only one PSL clock allowed per assertion");
// Block is the new expression to evaluate // Block is the new expression to evaluate
AstNode* blockp = nodep->propp()->unlinkFrBack(); AstNode* blockp = nodep->propp()->unlinkFrBack();
if (nodep->disablep()) { if (AstNode* const disablep = nodep->disablep()) {
m_disablep = nodep->disablep()->cloneTree(false); m_disablep = disablep->cloneTree(false);
if (VN_IS(nodep->backp(), Cover)) { if (VN_IS(nodep->backp(), Cover)) {
blockp = new AstAnd( blockp = new AstAnd(disablep->fileline(),
nodep->disablep()->fileline(), new AstNot(disablep->fileline(), disablep->unlinkFrBack()),
new AstNot(nodep->disablep()->fileline(), nodep->disablep()->unlinkFrBack()), blockp);
blockp);
} else { } else {
blockp = new AstOr(nodep->disablep()->fileline(), blockp = new AstOr(disablep->fileline(), disablep->unlinkFrBack(), blockp);
nodep->disablep()->unlinkFrBack(), blockp);
} }
} }
// Unlink and just keep a pointer to it, convert to sentree as needed // Unlink and just keep a pointer to it, convert to sentree as needed