mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 15:21:03 +00:00
Return empty string if GETRANGE of empty string
Previously, GETRANGE of a key containing nothing ("") would allocate a large (size_t)-1 return value causing crashes on 32bit builds when it tried to allocate the 4 GB return string.
This commit is contained in:
parent
f0e306f4a0
commit
b20df972ed
@ -259,7 +259,7 @@ void getrangeCommand(redisClient *c) {
|
|||||||
|
|
||||||
/* Precondition: end >= 0 && end < strlen, so the only condition where
|
/* Precondition: end >= 0 && end < strlen, so the only condition where
|
||||||
* nothing can be returned is: start > end. */
|
* nothing can be returned is: start > end. */
|
||||||
if (start > end) {
|
if (start > end || strlen == 0) {
|
||||||
addReply(c,shared.emptybulk);
|
addReply(c,shared.emptybulk);
|
||||||
} else {
|
} else {
|
||||||
addReplyBulkCBuffer(c,(char*)str+start,end-start+1);
|
addReplyBulkCBuffer(c,(char*)str+start,end-start+1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user