avoid lua stack overflow

This commit is contained in:
Cloud Wu
2015-10-14 15:24:51 +08:00
parent d2f2e299d5
commit 9aaa35ef14
2 changed files with 3 additions and 1 deletions

View File

@@ -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 };

View File

@@ -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;