Browse Source

* fix segfault in redis backend

master
Alex 'AdUser' Z 8 years ago
parent
commit
c07a8d0b86
  1. 6
      src/backends/redis.c

6
src/backends/redis.c

@ -50,11 +50,11 @@ redis_connect(cfg_t *cfg) {
if (!conn) if (!conn)
break; break;
if (conn->err) { if (conn->err) {
snprintf(cfg->error, sizeof(cfg->error), "Connection error: %s", cfg->conn->errstr); snprintf(cfg->error, sizeof(cfg->error), "Connection error: %s", conn->errstr);
break; break;
} }
if (cfg->password[0]) { if (cfg->password[0]) {
reply = redisCommand(cfg->conn, "AUTH %s", cfg->password); reply = redisCommand(conn, "AUTH %s", cfg->password);
if (reply->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_ERROR) {
snprintf(cfg->error, sizeof(cfg->error), "auth error: %s", reply->str); snprintf(cfg->error, sizeof(cfg->error), "auth error: %s", reply->str);
break; break;
@ -62,7 +62,7 @@ redis_connect(cfg_t *cfg) {
freeReplyObject(reply); freeReplyObject(reply);
} }
if (cfg->database) { if (cfg->database) {
reply = redisCommand(cfg->conn, "SELECT %d", cfg->database); reply = redisCommand(conn, "SELECT %d", cfg->database);
if (reply->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_ERROR) {
snprintf(cfg->error, sizeof(cfg->error), "auth error: %s", reply->str); snprintf(cfg->error, sizeof(cfg->error), "auth error: %s", reply->str);
break; break;

Loading…
Cancel
Save