'lua_setlocal' should not pop value when failing (to be consistent

with the manual and with 'lua_setupvalue')
This commit is contained in:
Roberto Ierusalimschy
2015-01-02 10:52:22 -02:00
parent 234fb7f695
commit 3a29087cb7
2 changed files with 11 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: ldebug.c,v 2.108 2014/12/08 15:48:23 roberto Exp roberto $
** $Id: ldebug.c,v 2.109 2014/12/10 11:30:09 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -167,9 +167,10 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
StkId pos = 0; /* to avoid warnings */
const char *name = findlocal(L, ar->i_ci, n, &pos);
lua_lock(L);
if (name)
if (name) {
setobjs2s(L, pos, L->top - 1);
L->top--; /* pop value */
L->top--; /* pop value */
}
lua_unlock(L);
return name;
}