[tarantool-patches] [PATCH] luajit: fox for debug.getinfo(1,'>S')

sergos at tarantool.org sergos at tarantool.org
Thu Aug 8 17:12:22 MSK 2019


fix for the debug machinery in case an extra argument
is expected on Lua stack

Fixes: #3833

https://github.com/tarantool/luajit/tree/sergos/luajit-gh-509-debug-getinfo-crash
---
 src/lj_debug.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/lj_debug.c b/src/lj_debug.c
index 959dc28..73bd196 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -427,12 +427,16 @@ int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext)
   TValue *frame = NULL;
   TValue *nextframe = NULL;
   GCfunc *fn;
-  if (*what == '>') {
-    TValue *func = L->top - 1;
-    api_check(L, tvisfunc(func));
-    fn = funcV(func);
-    L->top--;
-    what++;
+  if (*what == '>') { /* we have to have an extra arg on stack */
+    if (lua_gettop(L) > 2) {
+      TValue *func = L->top - 1;
+      api_check(L, tvisfunc(func));
+      fn = funcV(func);
+      L->top--;
+      what++;
+    } else { /* need better error to display? */
+      return 0;
+    }
   } else {
     uint32_t offset = (uint32_t)ar->i_ci & 0xffff;
     uint32_t size = (uint32_t)ar->i_ci >> 16;
-- 
2.17.1





More information about the Tarantool-patches mailing list