summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsunhe <sunheehnus@gmail.com>2016-10-22 01:54:46 +0800
committerantirez <antirez@gmail.com>2016-10-31 15:41:40 +0100
commit289fadb2d0393380a74f330aca7ad4660dbb3943 (patch)
treebad970a5a81aeac53284419c2416cebeb3a29088
parentf4f7d2c37fdac77c6bcc074dd00602b4e9699eec (diff)
downloadredis-289fadb2d0393380a74f330aca7ad4660dbb3943.tar.gz
bitops.c/bitfieldCommand: update higest_write_offset with check
-rw-r--r--src/bitops.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/bitops.c b/src/bitops.c
index 302e811d2..46eee22c3 100644
--- a/src/bitops.c
+++ b/src/bitops.c
@@ -907,7 +907,7 @@ void bitfieldCommand(client *c) {
struct bitfieldOp *ops = NULL; /* Array of ops to execute at end. */
int owtype = BFOVERFLOW_WRAP; /* Overflow type. */
int readonly = 1;
- long higest_write_offset = 0;
+ size_t higest_write_offset = 0;
for (j = 2; j < c->argc; j++) {
int remargs = c->argc-j-1; /* Remaining args other than current. */
@@ -957,7 +957,8 @@ void bitfieldCommand(client *c) {
if (opcode != BITFIELDOP_GET) {
readonly = 0;
- higest_write_offset = bitoffset + bits - 1;
+ if (higest_write_offset < bitoffset + bits - 1)
+ higest_write_offset = bitoffset + bits - 1;
/* INCRBY and SET require another argument. */
if (getLongLongFromObjectOrReply(c,c->argv[j+3],&i64,NULL) != C_OK){
zfree(ops);