mirror of
https://github.com/fluencelabs/redis
synced 2025-03-16 15:40:49 +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
|
||||
* nothing can be returned is: start > end. */
|
||||
if (start > end) {
|
||||
if (start > end || strlen == 0) {
|
||||
addReply(c,shared.emptybulk);
|
||||
} else {
|
||||
addReplyBulkCBuffer(c,(char*)str+start,end-start+1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user