From 9a69fcff7bf73f2ac22b8ee08cf2421cc3c7a9d4 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 18 May 2013 19:39:24 +0100 Subject: [PATCH] Handle out-of-bounds and undefined word indices in constant functions. --- net_func_eval.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net_func_eval.cc b/net_func_eval.cc index 0a616fe08..f5bef42c4 100644 --- a/net_func_eval.cc +++ b/net_func_eval.cc @@ -193,6 +193,9 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc, NetEConst*word_const = dynamic_cast(word_result); ivl_assert(loc, word_const); + if (!word_const->value().is_defined()) + return true; + word = word_const->value().as_long(); if (word >= ptr->second.nwords) @@ -683,7 +686,7 @@ NetExpr* NetESignal::evaluate_function(const LineInfo&loc, unsigned word = word_const->value().as_long(); - if (word < ptr->second.nwords) + if (word_const->value().is_defined() && (word < ptr->second.nwords)) value = ptr->second.array[word]; } else { value = ptr->second.value;