Fix null dereference crash in width process.

Signed-off-by: Wilson Snyder <wsnyder@wsnyder.org>
This commit is contained in:
John Coiner 2017-11-09 07:43:30 -05:00 committed by Wilson Snyder
parent f555c93c11
commit 5c919cd0de
1 changed files with 7 additions and 6 deletions

View File

@ -155,12 +155,13 @@ ostream& operator<<(ostream& str, const WidthVP* vup) {
class WidthClearVisitor { class WidthClearVisitor {
// Rather than a AstNVisitor, can just quickly touch every node // Rather than a AstNVisitor, can just quickly touch every node
void clearWidthRecurse(AstNode* nodep) { void clearWidthRecurse(AstNode* nodep) {
for (; nodep; nodep = nodep->nextp()) {
nodep->didWidth(false); nodep->didWidth(false);
if (nodep->op1p()) clearWidthRecurse(nodep->op1p()); if (nodep->op1p()) clearWidthRecurse(nodep->op1p());
if (nodep->op2p()) clearWidthRecurse(nodep->op2p()); if (nodep->op2p()) clearWidthRecurse(nodep->op2p());
if (nodep->op3p()) clearWidthRecurse(nodep->op3p()); if (nodep->op3p()) clearWidthRecurse(nodep->op3p());
if (nodep->op4p()) clearWidthRecurse(nodep->op4p()); if (nodep->op4p()) clearWidthRecurse(nodep->op4p());
if (nodep->nextp()) clearWidthRecurse(nodep->nextp()); }
} }
public: public:
// CONSTUCTORS // CONSTUCTORS