From: Vsevolod Stakhov Date: Wed, 16 Mar 2016 16:42:23 +0000 (+0000) Subject: [Fix] Fix couple of issues with arguments in lua_redis X-Git-Tag: 1.2.0~30 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=68cfcc69fb8217cc09f6b0bfe67d828c95bbc598;p=rspamd.git [Fix] Fix couple of issues with arguments in lua_redis --- diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index 4f09c3a96..abd25a93f 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -351,7 +351,9 @@ lua_redis_parse_args (lua_State *L, gint idx, const gchar *cmd, top = 1; while (lua_next (L, -2) != 0) { - args[top++] = g_strdup (lua_tostring (L, -1)); + if (lua_isstring (L, -1)) { + args[top++] = g_strdup (lua_tostring (L, -1)); + } lua_pop (L, 1); } @@ -874,10 +876,18 @@ lua_redis_connect_sync (lua_State *L) } if (ctx->d.sync == NULL || ctx->d.sync->err) { - REF_RELEASE (ctx); lua_pushboolean (L, FALSE); - return 1; + if (ctx->d.sync) { + lua_pushstring (L, ctx->d.sync->errstr); + } + else { + lua_pushstring (L, "unknown error"); + } + + REF_RELEASE (ctx); + + return 2; } pctx = lua_newuserdata (L, sizeof (ctx)); @@ -889,8 +899,10 @@ lua_redis_connect_sync (lua_State *L) if (ip) { rspamd_inet_address_destroy (ip); } - msg_err ("bad arguments for redis request"); + lua_pushboolean (L, FALSE); + lua_pushstring (L, "bad arguments for redis request"); + return 2; } return 1;