From fc843784c340865f105fa8da37001f044a613829 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 2 Mar 2016 16:20:28 +0100 Subject: [PATCH] BITFIELD: Farest bit set is offset+bits-1. Off by one error fixed. --- src/bitops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bitops.c b/src/bitops.c index 753db534..ed7e384a 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -964,8 +964,10 @@ void bitfieldCommand(client *c) { * for simplicity. SET return value is the previous value so * we need fetch & store as well. */ - if ((o = lookupStringForBitCommand(c,thisop->offset + thisop->bits)) - == NULL) return; + /* Lookup by making room up to the farest bit reached by + * this operation. */ + if ((o = lookupStringForBitCommand(c, + thisop->offset + (thisop->bits-1))) == NULL) return; /* We need two different but very similar code paths for signed * and unsigned operations, since the set of functions to get/set