diff options
author | Matt Stancliff <matt@genges.com> | 2014-09-02 18:56:28 -0400 |
---|---|---|
committer | Matt Stancliff <matt@genges.com> | 2014-09-02 18:56:28 -0400 |
commit | b20df972edf56c53a27d47839cdf58130bc6dfdc (patch) | |
tree | 56cd7f32ae41e848fa46ff0b2dcca0dcf6d635e9 /src/t_string.c | |
parent | f0e306f4a0bc0e4db15da54eb3d1d2337a1b6dea (diff) | |
download | redis-b20df972edf56c53a27d47839cdf58130bc6dfdc.tar.gz |
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.
Diffstat (limited to 'src/t_string.c')
-rw-r--r-- | src/t_string.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/t_string.c b/src/t_string.c index 2bf772a2d..f06693815 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -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); |