Skip to content

Commit 77aa564

Browse files
committed
luaL_checkstack accepts NULL message.
1 parent 5a462cd commit 77aa564

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

c-api/compat-5.3.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,18 @@ COMPAT53_API void luaL_checkversion (lua_State *L) {
155155
}
156156

157157

158+
COMPAT53_API void luaL_checkstack (lua_State *L, int sp, const char *msg) {
159+
if (!lua_checkstack(L, sp+LUA_MINSTACK)) {
160+
if (msg != NULL)
161+
luaL_error(L, "stack overflow (%s)", msg);
162+
else {
163+
lua_pushliteral(L, "stack overflow");
164+
lua_error(L);
165+
}
166+
}
167+
}
168+
169+
158170
COMPAT53_API int luaL_getsubtable (lua_State *L, int i, const char *name) {
159171
int abs_i = lua_absindex(L, i);
160172
luaL_checkstack(L, 3, "not enough stack slots");

c-api/compat-5.3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ COMPAT53_API lua_Number lua_tonumberx (lua_State *L, int i, int *isnum);
131131
#define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion)
132132
COMPAT53_API void luaL_checkversion (lua_State *L);
133133

134+
#define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53)
135+
COMPAT53_API void luaL_checkstack (lua_State *L, int sp, const char *msg);
136+
134137
#define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable)
135138
COMPAT53_API int luaL_getsubtable (lua_State* L, int i, const char *name);
136139

0 commit comments

Comments
 (0)