fix for namerefs referencing an unset array index with nounset enabled; addition to buildconf.h.in for C23 compilers

This commit is contained in:
Chet Ramey
2025-05-30 10:11:03 -04:00
parent 870ad4c92b
commit dbe4256d5e
24 changed files with 2285 additions and 3263 deletions
+19 -2
View File
@@ -10974,9 +10974,26 @@ comsub:
{
chk_atstar (temp, quoted, pflags, quoted_dollar_at_p, contains_dollar_at);
tdesc = parameter_brace_expand_word (temp, SPECIAL_VAR (temp, 0), quoted, pflags, 0);
free (temp1);
if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal)
return (tdesc);
{
free (temp1);
return (tdesc);
}
/* check for a nameref pointing to an unset array reference
where the subscript is not `@' or `*' and enforce nounset
if enabled. */
if ((tdesc == 0 || tdesc->word == 0) && unbound_vars_is_error)
{
char *sub;
sub = mbschr (temp, LBRACK);
if (DOLLAR_AT_STAR (sub[1]) == 0 || sub[2] != RBRACK)
{
temp = (char *)NULL;
goto unbound_variable;
}
}
free (temp1);
ret = tdesc;
goto return0;
}