From 9aaa35ef142da0d6e9ab0c6a2326ee8442716d6b Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 14 Oct 2015 15:24:51 +0800 Subject: [PATCH] avoid lua stack overflow --- lualib-src/lua-bson.c | 2 ++ skynet-src/skynet_timer.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lualib-src/lua-bson.c b/lualib-src/lua-bson.c index 0fc26985..bcd44162 100644 --- a/lualib-src/lua-bson.c +++ b/lualib-src/lua-bson.c @@ -408,6 +408,7 @@ bson_numstr( char *str, unsigned int i ) { static void pack_dict(lua_State *L, struct bson *b, bool isarray) { + luaL_checkstack(L, 16, NULL); // reserve enough stack space to pack table int length = reserve_length(b); lua_pushnil(L); while(lua_next(L,-2) != 0) { @@ -495,6 +496,7 @@ make_object(lua_State *L, int type, const void * ptr, size_t len) { static void unpack_dict(lua_State *L, struct bson_reader *br, bool array) { + luaL_checkstack(L, 16, NULL); // reserve enough stack space to unpack table int sz = read_int32(L, br); const void * bytes = read_bytes(L, br, sz-5); struct bson_reader t = { bytes, sz-5 }; diff --git a/skynet-src/skynet_timer.c b/skynet-src/skynet_timer.c index c9a113ae..1f366b85 100644 --- a/skynet-src/skynet_timer.c +++ b/skynet-src/skynet_timer.c @@ -208,7 +208,7 @@ timer_create_timer() { int skynet_timeout(uint32_t handle, int time, int session) { - if (time == 0) { + if (time <= 0) { struct skynet_message message; message.source = 0; message.session = session;