From 221d2932b51dc605130130369301c92f34336987 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 30 Mar 2015 11:54:49 +0200 Subject: [PATCH] Ensure array index is in range in addReplyLongLongWithPrefix(). Change done in order to remove a warning and improve code robustness. No actual bug here. --- src/networking.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/networking.c b/src/networking.c index ba35e487..a2d80adf 100644 --- a/src/networking.c +++ b/src/networking.c @@ -454,10 +454,10 @@ void addReplyLongLongWithPrefix(redisClient *c, long long ll, char prefix) { /* Things like $3\r\n or *2\r\n are emitted very often by the protocol * so we have a few shared objects to use if the integer is small * like it is most of the times. */ - if (prefix == '*' && ll < REDIS_SHARED_BULKHDR_LEN) { + if (prefix == '*' && ll < REDIS_SHARED_BULKHDR_LEN && ll >= 0) { addReply(c,shared.mbulkhdr[ll]); return; - } else if (prefix == '$' && ll < REDIS_SHARED_BULKHDR_LEN) { + } else if (prefix == '$' && ll < REDIS_SHARED_BULKHDR_LEN && ll >= 0) { addReply(c,shared.bulkhdr[ll]); return; }