mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
bug: expression list with four or more expressions in
a 'for' loop can crash the interpreter. ('adjust_assign' must remove extra expresssions from its registers.)
This commit is contained in:
parent
fac00ca023
commit
dcb2998aa6
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.152 2016/03/07 19:25:39 roberto Exp roberto $
|
** $Id: lparser.c,v 2.153 2016/05/13 19:10:16 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -323,6 +323,8 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
|
|||||||
luaK_nil(fs, reg, extra);
|
luaK_nil(fs, reg, extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nexps > nvars)
|
||||||
|
ls->fs->freereg -= nexps - nvars; /* remove extra values */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1160,11 +1162,8 @@ static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
|
|||||||
int nexps;
|
int nexps;
|
||||||
checknext(ls, '=');
|
checknext(ls, '=');
|
||||||
nexps = explist(ls, &e);
|
nexps = explist(ls, &e);
|
||||||
if (nexps != nvars) {
|
if (nexps != nvars)
|
||||||
adjust_assign(ls, nvars, nexps, &e);
|
adjust_assign(ls, nvars, nexps, &e);
|
||||||
if (nexps > nvars)
|
|
||||||
ls->fs->freereg -= nexps - nvars; /* remove extra values */
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
luaK_setoneret(ls->fs, &e); /* close last expression */
|
luaK_setoneret(ls->fs, &e); /* close last expression */
|
||||||
luaK_storevar(ls->fs, &lh->v, &e);
|
luaK_storevar(ls->fs, &lh->v, &e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user