提交 a3b0dbcc 编写于 作者: A antirez

Scripting: Fix for a #1118 regression simplified.

It is more straightforward to just test for a numerical type avoiding
Lua's automatic conversion. The code is technically more correct now,
however Lua should automatically convert to number only if the original
type is a string that "looks like a number", and not from other types,
so practically speaking the fix is identical AFAIK.
上级 ba76daa4
...@@ -200,11 +200,6 @@ void luaSortArray(lua_State *lua) { ...@@ -200,11 +200,6 @@ void luaSortArray(lua_State *lua) {
lua_pop(lua,1); /* Stack: array (sorted) */ lua_pop(lua,1); /* Stack: array (sorted) */
} }
int luaReallyIsString(lua_State *L, int index) {
int t = lua_type(L, index);
return t == LUA_TSTRING;
}
#define LUA_CMD_OBJCACHE_SIZE 32 #define LUA_CMD_OBJCACHE_SIZE 32
#define LUA_CMD_OBJCACHE_MAX_LEN 64 #define LUA_CMD_OBJCACHE_MAX_LEN 64
int luaRedisGenericCommand(lua_State *lua, int raise_error) { int luaRedisGenericCommand(lua_State *lua, int raise_error) {
...@@ -239,7 +234,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) { ...@@ -239,7 +234,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
size_t obj_len; size_t obj_len;
char dbuf[64]; char dbuf[64];
if (!luaReallyIsString(lua, j+1) && lua_isnumber(lua, j+1)) { if (lua_type(lua,j+1) == LUA_TNUMBER) {
/* We can't use lua_tolstring() for number -> string conversion /* We can't use lua_tolstring() for number -> string conversion
* since Lua uses a format specifier that loses precision. */ * since Lua uses a format specifier that loses precision. */
lua_Number num = lua_tonumber(lua,j+1); lua_Number num = lua_tonumber(lua,j+1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册