summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-03-30 11:54:49 +0200
committerantirez <antirez@gmail.com>2015-03-30 11:54:49 +0200
commit221d2932b51dc605130130369301c92f34336987 (patch)
treeafd4a5c9ba8bbd3c4ef9bef02616212b74c0b922
parent37260bc3bed5fb46649262789c65089ab7de0dc6 (diff)
downloadredis-221d2932b51dc605130130369301c92f34336987.tar.gz
Ensure array index is in range in addReplyLongLongWithPrefix().
Change done in order to remove a warning and improve code robustness. No actual bug here.
-rw-r--r--src/networking.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/networking.c b/src/networking.c
index ba35e487c..a2d80adf3 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;
}