fix minor mem leaks; fix problem with parser state during a DEBUG trap with -T enabled in a shell function; fix crash with propagating array variables; fix overflow in compound array appending

This commit is contained in:
Chet Ramey
2023-06-28 14:48:09 -04:00
parent 829aad36db
commit fa98070927
15 changed files with 557 additions and 399 deletions
+18 -2
View File
@@ -148,10 +148,17 @@ SHELL_VAR *
arrayvar_copyval (SHELL_VAR *v1, SHELL_VAR *v2)
{
FREE (value_cell (v2));
VUNSETATTR (v2, (att_array | att_assoc));
if (array_p (v1))
var_setarray (v2, array_copy (array_cell (v1)));
{
var_setarray (v2, array_copy (array_cell (v1)));
VSETATTR (v2, att_array);
}
else if (assoc_p (v1))
var_setassoc (v2, assoc_copy (assoc_cell (v1)));
{
var_setassoc (v2, assoc_copy (assoc_cell (v1)));
VSETATTR (v2, att_assoc);
}
return v2;
}
@@ -698,7 +705,16 @@ assign_compound_array_list (SHELL_VAR *var, WORD_LIST *nlist, int flags)
}
last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0;
if (a && last_ind < 0) /* overflow */
{
char *num;
num = itos (last_ind);
report_error ("%s[%s]: %s", var->name, num, bash_badsub_errmsg);
free (num);
return;
}
#if ASSOC_KVPAIR_ASSIGNMENT
if (assoc_p (var) && kvpair_assignment_p (nlist))
{