diff options
author | antirez <antirez@gmail.com> | 2016-02-26 15:53:29 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-02-26 15:53:29 +0100 |
commit | 11745e09810a531093b527d6161cbfc2ddd6ac91 (patch) | |
tree | 7626d23720a2f407792d577a9dd9dbbca3c074c7 /src/bitops.c | |
parent | 2800d090a7ca705b3dc03ae508511cea6bad650d (diff) | |
download | redis-11745e09810a531093b527d6161cbfc2ddd6ac91.tar.gz |
BITFIELD: Fix #<index> form parsing.
Diffstat (limited to 'src/bitops.c')
-rw-r--r-- | src/bitops.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/bitops.c b/src/bitops.c index d2e99fc80..4a1b3959d 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -398,20 +398,18 @@ int getBitOffsetFromArgument(client *c, robj *o, size_t *offset, int hash, int b char *err = "bit offset is not an integer or out of range"; char *p = o->ptr; size_t plen = sdslen(p); + int usehash = 0; /* Handle #<offset> form. */ - if (hash && bits > 0) { - p++; - plen--; - } + if (p[0] == '#' && hash && bits > 0) usehash = 1; - if (string2ll(p,plen,&loffset) == 0) { + if (string2ll(p+usehash,plen-usehash,&loffset) == 0) { addReplyError(c,err); return C_ERR; } /* Adjust the offset by 'bits' for #<offset> form. */ - if (hash && bits > 0) loffset *= bits; + if (usehash) loffset *= bits; /* Limit offset to 512MB in bytes */ if ((loffset < 0) || ((unsigned long long)loffset >> 3) >= (512*1024*1024)) |