summaryrefslogtreecommitdiff
path: root/src/t_string.c
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2014-09-02 18:56:28 -0400
committerMatt Stancliff <matt@genges.com>2014-09-02 18:56:28 -0400
commitb20df972edf56c53a27d47839cdf58130bc6dfdc (patch)
tree56cd7f32ae41e848fa46ff0b2dcca0dcf6d635e9 /src/t_string.c
parentf0e306f4a0bc0e4db15da54eb3d1d2337a1b6dea (diff)
downloadredis-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.c2
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);