Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
11745e09
Commit
11745e09
authored
Feb 26, 2016
by
antirez
Browse files
BITFIELD: Fix #<index> form parsing.
parent
2800d090
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/bitops.c
View file @
11745e09
...
@@ -398,20 +398,18 @@ int getBitOffsetFromArgument(client *c, robj *o, size_t *offset, int hash, int b
...
@@ -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
*
err
=
"bit offset is not an integer or out of range"
;
char
*
p
=
o
->
ptr
;
char
*
p
=
o
->
ptr
;
size_t
plen
=
sdslen
(
p
);
size_t
plen
=
sdslen
(
p
);
int
usehash
=
0
;
/* Handle #<offset> form. */
/* Handle #<offset> form. */
if
(
hash
&&
bits
>
0
)
{
if
(
p
[
0
]
==
'#'
&&
hash
&&
bits
>
0
)
usehash
=
1
;
p
++
;
plen
--
;
}
if
(
string2ll
(
p
,
plen
,
&
loffset
)
==
0
)
{
if
(
string2ll
(
p
+
usehash
,
plen
-
usehash
,
&
loffset
)
==
0
)
{
addReplyError
(
c
,
err
);
addReplyError
(
c
,
err
);
return
C_ERR
;
return
C_ERR
;
}
}
/* Adjust the offset by 'bits' for #<offset> form. */
/* Adjust the offset by 'bits' for #<offset> form. */
if
(
hash
&&
bits
>
0
)
loffset
*=
bits
;
if
(
use
hash
)
loffset
*=
bits
;
/* Limit offset to 512MB in bytes */
/* Limit offset to 512MB in bytes */
if
((
loffset
<
0
)
||
((
unsigned
long
long
)
loffset
>>
3
)
>=
(
512
*
1024
*
1024
))
if
((
loffset
<
0
)
||
((
unsigned
long
long
)
loffset
>>
3
)
>=
(
512
*
1024
*
1024
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment