Skip to content

Commit

Permalink
Fix an hypothetical issue in processMultibulkBuffer().
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Aug 27, 2013
1 parent 8811d49 commit e29e426
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/networking.c
Expand Up @@ -987,15 +987,19 @@ int processMultibulkBuffer(redisClient *c) {

pos += newline-(c->querybuf+pos)+2;
if (ll >= REDIS_MBULK_BIG_ARG) {
size_t qblen;

/* If we are going to read a large object from network
* try to make it likely that it will start at c->querybuf
* boundary so that we can optimize object creation
* avoiding a large copy of data. */
sdsrange(c->querybuf,pos,-1);
pos = 0;
qblen = sdslen(c->querybuf);
/* Hint the sds library about the amount of bytes this string is
* going to contain. */
c->querybuf = sdsMakeRoomFor(c->querybuf,ll+2-sdslen(c->querybuf));
if (qblen < ll+2)
c->querybuf = sdsMakeRoomFor(c->querybuf,ll+2-qblen);
}
c->bulklen = ll;
}
Expand Down

0 comments on commit e29e426

Please sign in to comment.