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-16 02:50:32 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-16 02:50:32 -0800
commit7c1b9d0b91295323b5ed5ec3e09b46566288bc75 (patch)
treef6a2955d3cec464ace740e88e215a201d6a87cbf /src/lua.c
parentb425593af6689c14e816dddc0e733636d78d99f1 (diff)
downloadteliva-7c1b9d0b91295323b5ed5ec3e09b46566288bc75.tar.gz
stop leaking on the Lua stack
..even if at the expense of leaking on the heap. Because the Lua stack
has very limited space (~20 slots). When it overflows, we segfault.
Diffstat (limited to 'src/lua.c')
-rw-r--r--src/lua.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lua.c b/src/lua.c
index ac6e249..834e547 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -901,10 +901,10 @@ int restore_editor_view (lua_State *L) {
     status = load_editor_buffer_to_current_definition_in_image(L);
     if (status == 0 || lua_isnil(L, -1))
       break;
-    Previous_error = lua_tostring(L, -1);
+    Previous_error = strdup(lua_tostring(L, -1));  /* memory leak */
     if (Previous_error == NULL) Previous_error = "(error object is not a string)";
-    back_to_big_picture = resumeEdit(L);
     lua_pop(L, 1);
+    back_to_big_picture = resumeEdit(L);
   }
   return back_to_big_picture;
 }