mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
bson bugfix
This commit is contained in:
@@ -243,12 +243,16 @@ append_key(struct bson *bs, int type, const char *key, size_t sz) {
|
||||
write_string(bs, key, sz);
|
||||
}
|
||||
|
||||
static inline int
|
||||
is_32bit(int64_t v) {
|
||||
return v >= INT32_MIN && v <= INT32_MAX;
|
||||
}
|
||||
|
||||
static void
|
||||
append_number(struct bson *bs, lua_State *L, const char *key, size_t sz) {
|
||||
if (lua_isinteger(L, -1)) {
|
||||
int64_t i = lua_tointeger(L, -1);
|
||||
int si = i >> 31;
|
||||
if (si == 0 || si == -1) {
|
||||
if (is_32bit(i)) {
|
||||
append_key(bs, BSON_INT32, key, sz);
|
||||
write_int32(bs, i);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user