Skip to content

Commit

Permalink
A fix for the endless recursion and segfault for declarations like "p…
Browse files Browse the repository at this point in the history
…aram a := 2; param b := a * b; display a,b;"
  • Loading branch information
mingodad committed Dec 17, 2021
1 parent 1397315 commit fbcc066
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/mpl/mpl1.c
Expand Up @@ -3578,8 +3578,9 @@ PARAMETER *parameter_statement(MPL *mpl)
{ par->domain = indexing_expression(mpl);
par->dim = domain_arity(mpl, par->domain);
}
/* include the parameter name in the symbolic names table */
{ AVLNODE *node;
if(par->dim != 0) { /* To prevent endless recursion delay insertion */
/* include the parameter name in the symbolic names table */
AVLNODE *node;
node = avl_insert_node(mpl->tree, par->name);
avl_set_node_type(node, A_PARAMETER);
avl_set_node_link(node, (void *)par);
Expand Down Expand Up @@ -3765,6 +3766,13 @@ err: error(mpl, "at most one := or default allowed");
else
error(mpl, "syntax error in parameter statement");
}
if(par->dim == 0) { /* Delayed insertion to prevent endless recursion */
/* include the parameter name in the symbolic names table */
AVLNODE *node;
node = avl_insert_node(mpl->tree, par->name);
avl_set_node_type(node, A_PARAMETER);
avl_set_node_link(node, (void *)par);
}
/* close the domain scope */
if (par->domain != NULL) close_scope(mpl, par->domain);
/* the parameter statement has been completely parsed */
Expand Down

0 comments on commit fbcc066

Please sign in to comment.