about summary refs log tree commit diff stats
path: root/src/lua.c
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-12-17 21:58:56 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-17 22:23:18 -0800
commitc12ba48a630474e0d53ead2770bd1887463c5915 (patch)
tree473924e6bd53e15ef9aed478df669219b38c8551 /src/lua.c
parent92fe487349d2903e2fd118215547fe2db1f8739f (diff)
downloadteliva-c12ba48a630474e0d53ead2770bd1887463c5915.tar.gz
one more protection against Lua stack leak
Diffstat (limited to 'src/lua.c')
-rw-r--r--src/lua.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lua.c b/src/lua.c
index 94964cb..d95ac99 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -765,7 +765,7 @@ static void big_picture_menu (void) {
 static int is_current_definition(lua_State *L, const char *definition_name, int current_history_array_index, int history_array_location, int history_array_size) {
   /* Sequentially scan back through history_array until current_history_array_index.
    * Is there an earlier definition of definition_name? */
-//?   int oldsize = L->top-L->stack;
+  int oldtop = lua_gettop(L);
   int found = 0;
   for (int i = history_array_size; i > current_history_array_index; --i) {
     lua_rawgeti(L, history_array_location, i);
@@ -784,11 +784,11 @@ static int is_current_definition(lua_State *L, const char *definition_name, int
     if (found)
       break;
   }
-//?   if(oldsize != L->top-L->stack) {
-//?     endwin();
-//?     printf("%d %d\n", oldsize, L->top-L->stack);
-//?     exit(1);
-//?   }
+  if(oldtop != lua_gettop(L)) {
+    endwin();
+    printf("%d %d\n", oldtop, lua_gettop(L));
+    exit(1);
+  }
   return !found;
 }