Skip to content

Commit 221d293

Browse files
committed
Ensure array index is in range in addReplyLongLongWithPrefix().
Change done in order to remove a warning and improve code robustness. No actual bug here.
1 parent 37260bc commit 221d293

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/networking.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,10 @@ void addReplyLongLongWithPrefix(redisClient *c, long long ll, char prefix) {
454454
/* Things like $3\r\n or *2\r\n are emitted very often by the protocol
455455
* so we have a few shared objects to use if the integer is small
456456
* like it is most of the times. */
457-
if (prefix == '*' && ll < REDIS_SHARED_BULKHDR_LEN) {
457+
if (prefix == '*' && ll < REDIS_SHARED_BULKHDR_LEN && ll >= 0) {
458458
addReply(c,shared.mbulkhdr[ll]);
459459
return;
460-
} else if (prefix == '$' && ll < REDIS_SHARED_BULKHDR_LEN) {
460+
} else if (prefix == '$' && ll < REDIS_SHARED_BULKHDR_LEN && ll >= 0) {
461461
addReply(c,shared.bulkhdr[ll]);
462462
return;
463463
}

0 commit comments

Comments
 (0)