For default function arguments do not access an out of range real argument.

The code should only look at the real argument that exist any missing
arguments default to not being defined and hence needs to use the
default expression. Found with valgrind.
This commit is contained in:
Cary R 2013-11-20 16:48:15 -08:00
parent 676786a399
commit f47af361cd
1 changed files with 2 additions and 1 deletions

View File

@ -2145,10 +2145,11 @@ unsigned PECallFunction::elaborate_arguments_(Design*des, NetScope*scope,
unsigned missing_parms = 0; unsigned missing_parms = 0;
const unsigned parm_count = parms.size() - parm_off; const unsigned parm_count = parms.size() - parm_off;
const unsigned actual_count = parms_.size();
for (unsigned idx = 0 ; idx < parm_count ; idx += 1) { for (unsigned idx = 0 ; idx < parm_count ; idx += 1) {
unsigned pidx = idx + parm_off; unsigned pidx = idx + parm_off;
PExpr*tmp = parms_[idx]; PExpr*tmp = (idx < actual_count) ? parms_[idx] : 0;
if (tmp) { if (tmp) {
parms[pidx] = elaborate_rval_expr(des, scope, parms[pidx] = elaborate_rval_expr(des, scope,
def->port(pidx)->net_type(), def->port(pidx)->net_type(),