aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-29 19:05:07 +0200
committerdaurnimator <quae@daurnimator.com>2017-05-31 22:26:56 +1000
commit2e9c10dd6f9b9fd83b7424eb10684570b663348b (patch)
treeb6ef9277a25fa088ceef84bfe2ccbfc117d0bff0 /src
parentda7551f134377574bbda7dfe5b73e3989fddeb77 (diff)
downloadfengari-2e9c10dd6f9b9fd83b7424eb10684570b663348b.tar.gz
fengari-2e9c10dd6f9b9fd83b7424eb10684570b663348b.tar.bz2
fengari-2e9c10dd6f9b9fd83b7424eb10684570b663348b.zip
src/ldebug.js: Test for null result of findlocal in lua_setlocal
Diffstat (limited to 'src')
-rw-r--r--src/ldebug.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ldebug.js b/src/ldebug.js
index 4f8d385..532fd9c 100644
--- a/src/ldebug.js
+++ b/src/ldebug.js
@@ -151,13 +151,15 @@ const lua_getlocal = function(L, ar, n) {
};
const lua_setlocal = function(L, ar, n) {
+ let name;
swapextra(L);
let local = findlocal(L, ar.i_ci, n);
- let name = local.name;
- let pos = local.pos;
- if (name) {
- lobject.setobjs2s(L, pos, L.top - 1);
+ if (local) {
+ name = local.name;
+ lobject.setobjs2s(L, local.pos, L.top - 1);
delete L.stack[--L.top]; /* pop value */
+ } else {
+ name = null;
}
swapextra(L);
return name;