Skip to content

Commit

Permalink
fix(ubus): fix lua table to blob for integer
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Sep 5, 2023
1 parent 51c9c5d commit e65f96f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ static void lua_table_to_blob(lua_State *L, int index, struct blob_buf *b, bool
break;

case LUA_TNUMBER: {
if (lua_isinteger(L, -1))
blobmsg_add_u64(b, key, lua_tointeger(L, -1));
else
if (lua_isinteger(L, -1)) {
int64_t v = lua_tointeger(L, -1);
if (v > INT32_MAX)
blobmsg_add_u64(b, key, v);
else
blobmsg_add_u32(b, key, v);
} else {
blobmsg_add_double(b, key, lua_tonumber(L, -1));
}
break;
}

Expand Down

0 comments on commit e65f96f

Please sign in to comment.