diff options
author | antirez <antirez@gmail.com> | 2013-08-27 13:00:06 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-08-27 13:00:17 +0200 |
commit | ef0fa0895ad3507844877992bc46706bc1af18bd (patch) | |
tree | 5ee205abba17e466647ef193dbecbbd05e4c89fe | |
parent | e3cbc018a38727423c1dc5ac53178664c771f08e (diff) | |
download | redis-ef0fa0895ad3507844877992bc46706bc1af18bd.tar.gz |
Fix an hypothetical issue in processMultibulkBuffer().
-rw-r--r-- | src/networking.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c index dc8b358c2..13c4314fe 100644 --- a/src/networking.c +++ b/src/networking.c @@ -925,15 +925,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. */ c->querybuf = 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; } |