Bug: check for constructor overflow in [exp] fields

The check for constructor overflow was considering only fields with
explicit names, ignoring fields with syntax '[exp]=exp'.
This commit is contained in:
Roberto Ierusalimschy
2025-05-20 17:50:56 -03:00
parent be05c44481
commit c15543b9af
2 changed files with 5 additions and 6 deletions

View File

@@ -904,12 +904,11 @@ static void recfield (LexState *ls, ConsControl *cc) {
FuncState *fs = ls->fs;
lu_byte reg = ls->fs->freereg;
expdesc tab, key, val;
if (ls->t.token == TK_NAME) {
luaY_checklimit(fs, cc->nh, INT_MAX / 2, "items in a constructor");
if (ls->t.token == TK_NAME)
codename(ls, &key);
}
else /* ls->t.token == '[' */
yindex(ls, &key);
luaY_checklimit(fs, cc->nh, INT_MAX / 2, "items in a constructor");
cc->nh++;
checknext(ls, '=');
tab = *cc->t;