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
8fe7fad7
Commit
8fe7fad7
authored
Mar 04, 2010
by
antirez
Browse files
SUBSTR fix for integer encoded vals
parent
67cac143
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
8fe7fad7
...
...
@@ -3778,9 +3778,12 @@ static void substrCommand(redisClient *c) {
if (o->type != REDIS_STRING) {
addReply(c,shared.wrongtypeerr);
} else {
size_t rangelen, strlen
= sdslen(o->ptr)
;
size_t rangelen, strlen;
sds range;
o = getDecodedObject(o);
strlen = sdslen(o->ptr);
/* convert negative indexes */
if (start < 0) start = strlen+start;
if (end < 0) end = strlen+end;
...
...
@@ -3791,6 +3794,7 @@ static void substrCommand(redisClient *c) {
if (start > end || (size_t)start >= strlen) {
/* Out of range start or start > end result in null reply */
addReply(c,shared.nullbulk);
decrRefCount(o);
return;
}
if ((size_t)end >= strlen) end = strlen-1;
...
...
@@ -3801,6 +3805,7 @@ static void substrCommand(redisClient *c) {
range = sdsnewlen((char*)o->ptr+start,rangelen);
addReplySds(c,range);
addReply(c,shared.crlf);
decrRefCount(o);
}
}
}
...
...
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