summaryrefslogtreecommitdiff
path: root/src/bitops.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-06-15 12:48:58 +0200
committerantirez <antirez@gmail.com>2016-06-15 12:48:58 +0200
commit2d86995273e431b40c2bd30c694ea405cc698118 (patch)
tree6db769a82f96a377bf64aee86a6203aa282e18ff /src/bitops.c
parenteb45e114965175e766136d6e0d8fbe242bc256b1 (diff)
downloadredis-2d86995273e431b40c2bd30c694ea405cc698118.tar.gz
GETRANGE: return empty string with negative, inverted start/end.
Diffstat (limited to 'src/bitops.c')
-rw-r--r--src/bitops.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bitops.c b/src/bitops.c
index 2312432fc..781cc58d6 100644
--- a/src/bitops.c
+++ b/src/bitops.c
@@ -773,12 +773,12 @@ void bitcountCommand(client *c) {
if (getLongFromObjectOrReply(c,c->argv[3],&end,NULL) != C_OK)
return;
/* Convert negative indexes */
- if (start < 0) start = strlen+start;
- if (end < 0) end = strlen+end;
if (start < 0 && end < 0 && start > end) {
addReply(c,shared.czero);
return;
}
+ if (start < 0) start = strlen+start;
+ if (end < 0) end = strlen+end;
if (start < 0) start = 0;
if (end < 0) end = 0;
if (end >= strlen) end = strlen-1;