diff --git a/src/bitops.c b/src/bitops.c index a7fad899f..f3a7747b4 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -768,6 +768,10 @@ void bitcountCommand(client *c) { /* 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 = 0; if (end < 0) end = 0; if (end >= strlen) end = strlen-1;