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)
This commit is contained in:
Huang Zw 2021-02-02 16:54:19 +08:00 committed by GitHub
parent f05aa7a85a
commit 54ca166f1c

View File

@ -717,9 +717,6 @@ void addReplyLongLong(client *c, long long ll) {
void addReplyAggregateLen(client *c, long length, int prefix) { void addReplyAggregateLen(client *c, long length, int prefix) {
serverAssert(length >= 0); serverAssert(length >= 0);
if (prefix == '*' && length < OBJ_SHARED_BULKHDR_LEN)
addReply(c,shared.mbulkhdr[length]);
else
addReplyLongLongWithPrefix(c,length,prefix); addReplyLongLongWithPrefix(c,length,prefix);
} }
@ -781,9 +778,6 @@ void addReplyNullArray(client *c) {
void addReplyBulkLen(client *c, robj *obj) { void addReplyBulkLen(client *c, robj *obj) {
size_t len = stringObjectLen(obj); size_t len = stringObjectLen(obj);
if (len < OBJ_SHARED_BULKHDR_LEN)
addReply(c,shared.bulkhdr[len]);
else
addReplyLongLongWithPrefix(c,len,'$'); addReplyLongLongWithPrefix(c,len,'$');
} }