From 2e9c10dd6f9b9fd83b7424eb10684570b663348b Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Mon, 29 May 2017 19:05:07 +0200 Subject: src/ldebug.js: Test for null result of findlocal in lua_setlocal --- src/ldebug.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-70-g09d2