]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Preserve stack top across implicit load of FFI library in lexer.
authorMike Pall <mike>
Sun, 9 Jan 2011 16:48:25 +0000 (17:48 +0100)
committerMike Pall <mike>
Sun, 9 Jan 2011 16:57:19 +0000 (17:57 +0100)
src/Makefile.dep
src/lj_lex.c

index 9982f7b057bb5a5329d629ad6899fa243e426fc4..8481b9f0db4b88d6b57004010417e1f02311f4d1 100644 (file)
@@ -97,7 +97,7 @@ lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
  lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h lj_lib.h
 lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
  lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cdata.h lualib.h \
- lj_lex.h lj_parse.h lj_char.h
+ lj_state.h lj_lex.h lj_parse.h lj_char.h
 lj_lib.o: lj_lib.c lauxlib.h lua.h luaconf.h lj_obj.h lj_def.h lj_arch.h \
  lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_bc.h \
  lj_dispatch.h lj_jit.h lj_ir.h lj_vm.h lj_lib.h
index c97d6e0ef95a50419344cbce5c173557b1196c45..ac0d1e95fade8635a90b36e9dfa6a14025fa7e8a 100644 (file)
@@ -19,6 +19,7 @@
 #include "lj_cdata.h"
 #include "lualib.h"
 #endif
+#include "lj_state.h"
 #include "lj_lex.h"
 #include "lj_parse.h"
 #include "lj_char.h"
@@ -87,6 +88,7 @@ static void inclinenumber(LexState *ls)
 /* Load FFI library on-demand. Needed if we create cdata objects. */
 static void lex_loadffi(lua_State *L)
 {
+  ptrdiff_t oldtop = savestack(L, L->top);
   cTValue *tmp;
   luaopen_ffi(L);
   tmp = lj_tab_getstr(tabV(registry(L)), lj_str_newlit(L, "_LOADED"));
@@ -95,7 +97,7 @@ static void lex_loadffi(lua_State *L)
     copyTV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "ffi")), L->top-1);
     lj_gc_anybarriert(L, t);
   }
-  L->top--;
+  L->top = restorestack(L, oldtop);
 }
 
 /* Parse 64 bit integer. */