Unverified Commit 9760475a authored by Huang Zw's avatar Huang Zw Committed by GitHub
Browse files

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)
parent f2a5fe36
...@@ -717,10 +717,7 @@ void addReplyLongLong(client *c, long long ll) { ...@@ -717,10 +717,7 @@ 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) addReplyLongLongWithPrefix(c,length,prefix);
addReply(c,shared.mbulkhdr[length]);
else
addReplyLongLongWithPrefix(c,length,prefix);
} }
void addReplyArrayLen(client *c, long length) { void addReplyArrayLen(client *c, long length) {
...@@ -781,10 +778,7 @@ void addReplyNullArray(client *c) { ...@@ -781,10 +778,7 @@ 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) addReplyLongLongWithPrefix(c,len,'$');
addReply(c,shared.bulkhdr[len]);
else
addReplyLongLongWithPrefix(c,len,'$');
} }
/* Add a Redis Object as a bulk reply */ /* Add a Redis Object as a bulk reply */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment