diff --git a/src/redis.c b/src/redis.c index b781ebd6..c87b9ac2 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2207,7 +2207,13 @@ int processCommand(redisClient *c) { * is returning an error. */ if (server.maxmemory) { int retval = freeMemoryIfNeeded(); - if ((c->cmd->flags & REDIS_CMD_DENYOOM) && retval == REDIS_ERR) { + /* freeMemoryIfNeeded may flush slave output buffers. This may result + * into a slave, that may be the active client, to be freed. */ + if (server.current_client == NULL) return REDIS_ERR; + + /* It was impossible to free enough memory, and the command the client + * is trying to execute is denied during OOM conditions? Error. */ + if ((c->cmd->flags & CMD_DENYOOM) && retval == REDIS_ERR) { flagTransaction(c); addReply(c, shared.oomerr); return REDIS_OK;