Skip to content

Commit 9aaa35e

Browse files
committed
avoid lua stack overflow
1 parent d2f2e29 commit 9aaa35e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lualib-src/lua-bson.c

+2
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ bson_numstr( char *str, unsigned int i ) {
408408

409409
static void
410410
pack_dict(lua_State *L, struct bson *b, bool isarray) {
411+
luaL_checkstack(L, 16, NULL); // reserve enough stack space to pack table
411412
int length = reserve_length(b);
412413
lua_pushnil(L);
413414
while(lua_next(L,-2) != 0) {
@@ -495,6 +496,7 @@ make_object(lua_State *L, int type, const void * ptr, size_t len) {
495496

496497
static void
497498
unpack_dict(lua_State *L, struct bson_reader *br, bool array) {
499+
luaL_checkstack(L, 16, NULL); // reserve enough stack space to unpack table
498500
int sz = read_int32(L, br);
499501
const void * bytes = read_bytes(L, br, sz-5);
500502
struct bson_reader t = { bytes, sz-5 };

skynet-src/skynet_timer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ timer_create_timer() {
208208

209209
int
210210
skynet_timeout(uint32_t handle, int time, int session) {
211-
if (time == 0) {
211+
if (time <= 0) {
212212
struct skynet_message message;
213213
message.source = 0;
214214
message.session = session;

0 commit comments

Comments
 (0)