From aa2a063bc06922e0e064dce0b16d1ea6a4c9a7c6 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 5 Oct 2011 10:41:24 -0700 Subject: [PATCH] Remove the use of a freed variable. If a constant is padded the original constant will be freed and replaced with a new one. This results in the ce pointer pointing to freed memory. In reality the second check only needs to be done if the first one is false so avoid the whole issue by only performing the second check if the first on is false. --- netmisc.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/netmisc.cc b/netmisc.cc index ec50f45e3..b9abaad93 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -589,8 +589,7 @@ void eval_expr(NetExpr*&expr, int context_width) // The expression is a constant, so resize it if needed. if (ce->expr_width() < (unsigned)context_width) { expr = pad_to_width(expr, context_width, *expr); - } - if (ce->expr_width() > (unsigned)context_width) { + } else if (ce->expr_width() > (unsigned)context_width) { verinum value(ce->value(), context_width); ce = new NetEConst(value); ce->set_line(*expr);