diff --git a/HISTORY.md b/HISTORY.md index 76e7dc61..07a4c501 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +Dev version +----------- +* Bugfix: update lua-bson (signed 32bit int bug) + v0.2.1 (2014-5-19) ----------- * Bugfix: check all the events already read after socket close diff --git a/lualib-src/lua-bson.c b/lualib-src/lua-bson.c index e129f62b..077e538e 100644 --- a/lualib-src/lua-bson.c +++ b/lualib-src/lua-bson.c @@ -1,5 +1,3 @@ -#include "skynet_malloc.h" - #include #include @@ -73,7 +71,7 @@ struct bson_reader { static inline void bson_destroy(struct bson *b) { if (b->ptr != b->buffer) { - skynet_free(b->ptr); + free(b->ptr); } } @@ -93,10 +91,10 @@ bson_reserve(struct bson *b, int sz) { } while (b->cap <= b->size + sz); if (b->ptr == b->buffer) { - b->ptr = skynet_malloc(b->cap); + b->ptr = malloc(b->cap); memcpy(b->ptr, b->buffer, b->size); } else { - b->ptr = skynet_realloc(b->ptr, b->cap); + b->ptr = realloc(b->ptr, b->cap); } } @@ -258,13 +256,13 @@ append_key(struct bson *bs, int type, const char *key, size_t sz) { static void append_number(struct bson *bs, lua_State *L, const char *key, size_t sz) { - lua_Integer i = lua_tointeger(L, -1); + int64_t i = lua_tointeger(L, -1); lua_Number d = lua_tonumber(L,-1); if (i != d) { append_key(bs, BSON_REAL, key, sz); write_double(bs, d); } else { - int si = (int64_t)i >> 32; + int si = i >> 31; if (si == 0 || si == -1) { append_key(bs, BSON_INT32, key, sz); write_int32(bs, i); @@ -459,7 +457,7 @@ pack_dict(lua_State *L, struct bson *b, bool isarray) { } static void -pack_sorted_dict(lua_State *L, struct bson *b, int n) { +pack_ordered_dict(lua_State *L, struct bson *b, int n) { int length = reserve_length(b); int i; for (i=0;i