From 9760475a3984b88b9fcec07392e3ebd998461841 Mon Sep 17 00:00:00 2001 From: Huang Zw Date: Tue, 2 Feb 2021 16:54:19 +0800 Subject: [PATCH] Cleanup: addReplyAggregateLen and addReplyBulkLen remove redundant check (#8431) addReplyLongLongWithPrefix, has a check against negative length, and the code flow removed in this commit bypasses the check. addReplyAggregateLen has an assertion for negative length, but addReplyBulkLen does not, so this commit fixes theoretical case of access violation (probably unreachable though) --- src/networking.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/networking.c b/src/networking.c index da611675c..f9a3ff86a 100644 --- a/src/networking.c +++ b/src/networking.c @@ -717,10 +717,7 @@ void addReplyLongLong(client *c, long long ll) { void addReplyAggregateLen(client *c, long length, int prefix) { serverAssert(length >= 0); - if (prefix == '*' && length < OBJ_SHARED_BULKHDR_LEN) - addReply(c,shared.mbulkhdr[length]); - else - addReplyLongLongWithPrefix(c,length,prefix); + addReplyLongLongWithPrefix(c,length,prefix); } void addReplyArrayLen(client *c, long length) { @@ -781,10 +778,7 @@ void addReplyNullArray(client *c) { void addReplyBulkLen(client *c, robj *obj) { size_t len = stringObjectLen(obj); - if (len < OBJ_SHARED_BULKHDR_LEN) - addReply(c,shared.bulkhdr[len]); - else - addReplyLongLongWithPrefix(c,len,'$'); + addReplyLongLongWithPrefix(c,len,'$'); } /* Add a Redis Object as a bulk reply */