Commit f45fa5d0 authored by wenduo's avatar wenduo Committed by antirez
Browse files

bitcount bug:return non-zero value when start > end (both negative)

parent 0cb86064
...@@ -775,6 +775,10 @@ void bitcountCommand(client *c) { ...@@ -775,6 +775,10 @@ void bitcountCommand(client *c) {
/* Convert negative indexes */ /* Convert negative indexes */
if (start < 0) start = strlen+start; if (start < 0) start = strlen+start;
if (end < 0) end = strlen+end; if (end < 0) end = strlen+end;
if ((start < 0) && (end < 0) && (start > end)) {
addReply(c,shared.czero);
return;
}
if (start < 0) start = 0; if (start < 0) start = 0;
if (end < 0) end = 0; if (end < 0) end = 0;
if (end >= strlen) end = strlen-1; if (end >= strlen) end = strlen-1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment