From 5c919cd0de7f11af4f83e78760f56e9d1957047d Mon Sep 17 00:00:00 2001 From: John Coiner Date: Thu, 9 Nov 2017 07:43:30 -0500 Subject: [PATCH] Fix null dereference crash in width process. Signed-off-by: Wilson Snyder --- src/V3Width.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 2c29e0d02..a78ec6cd5 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -155,12 +155,13 @@ ostream& operator<<(ostream& str, const WidthVP* vup) { class WidthClearVisitor { // Rather than a AstNVisitor, can just quickly touch every node void clearWidthRecurse(AstNode* nodep) { - nodep->didWidth(false); - if (nodep->op1p()) clearWidthRecurse(nodep->op1p()); - if (nodep->op2p()) clearWidthRecurse(nodep->op2p()); - if (nodep->op3p()) clearWidthRecurse(nodep->op3p()); - if (nodep->op4p()) clearWidthRecurse(nodep->op4p()); - if (nodep->nextp()) clearWidthRecurse(nodep->nextp()); + for (; nodep; nodep = nodep->nextp()) { + nodep->didWidth(false); + if (nodep->op1p()) clearWidthRecurse(nodep->op1p()); + if (nodep->op2p()) clearWidthRecurse(nodep->op2p()); + if (nodep->op3p()) clearWidthRecurse(nodep->op3p()); + if (nodep->op4p()) clearWidthRecurse(nodep->op4p()); + } } public: // CONSTUCTORS