Skip to content

Commit b8d0f7b

Browse files
committed
Test fix for #7787 (Map Editor crashes after pressing "Stop Testing")
1 parent 839732e commit b8d0f7b

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/lapi.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ LUA_API int lua_checkstack (lua_State *L, int size) {
106106
return res;
107107
}
108108

109+
// MTA addition - Return stack space
110+
LUA_API int lua_getstackgap (lua_State *L) {
111+
int res, gap1, gap2;
112+
lua_lock(L);
113+
gap1 = ( (char *)L->stack_last - (char *)L->top ) / (int)sizeof(TValue);
114+
gap2 = L->ci->top - L->top;
115+
res = gap1 < gap2 ? gap1 : gap2;
116+
lua_unlock(L);
117+
return res;
118+
}
109119

110120
LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
111121
int i;

src/lua.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
9191

9292

9393
/* minimum Lua stack available to a C function */
94-
#define LUA_MINSTACK 20
94+
#define LUA_MINSTACK 40 // MTA change. Was 20
9595

9696

9797
/*
@@ -134,6 +134,7 @@ LUA_API void (lua_remove) (lua_State *L, int idx);
134134
LUA_API void (lua_insert) (lua_State *L, int idx);
135135
LUA_API void (lua_replace) (lua_State *L, int idx);
136136
LUA_API int (lua_checkstack) (lua_State *L, int sz);
137+
LUA_API int (lua_getstackgap) (lua_State *L); // MTA addition
137138

138139
LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
139140

src/lua5.1.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ EXPORTS
1919
lua_lessthan
2020
lua_rawequal
2121
lua_checkstack
22+
lua_getstackgap
2223
lua_cpcall
2324
lua_error
2425
lua_getmetatable

0 commit comments

Comments
 (0)