summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-06-11 10:10:58 +0200
committerantirez <antirez@gmail.com>2014-06-11 10:14:26 +0200
commita3b0dbccf560dcc13f4cdec8c43ab6bca7137065 (patch)
treea3d1eedf03a9e729f3d4ee4ba2e7d60af75b8b9b
parentba76daa42eea52c2c3a55cfdd40cf3d0b6e968d0 (diff)
downloadredis-a3b0dbccf560dcc13f4cdec8c43ab6bca7137065.tar.gz
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.
-rw-r--r--src/scripting.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/scripting.c b/src/scripting.c
index 0b6d848ec..0a636d80c 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -200,11 +200,6 @@ void luaSortArray(lua_State *lua) {
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_MAX_LEN 64
int luaRedisGenericCommand(lua_State *lua, int raise_error) {
@@ -239,7 +234,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
size_t obj_len;
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
* since Lua uses a format specifier that loses precision. */
lua_Number num = lua_tonumber(lua,j+1);