summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-08-27 11:54:38 +0200
committerantirez <antirez@gmail.com>2013-08-27 12:51:51 +0200
commit84472a3565a4230bded455f0f39ffac9741fa7ab (patch)
treecc7f835190683ee6209fea7241fbaac607bf8918
parente5fe66efe9f9b67ce6f9d06f919645756a588d6f (diff)
downloadredis-84472a3565a4230bded455f0f39ffac9741fa7ab.tar.gz
Don't over-allocate the sds string for large bulk requests.
The call to sdsMakeRoomFor() did not accounted for the amount of data already present in the query buffer, resulting into over-allocation.
-rw-r--r--src/networking.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/networking.c b/src/networking.c
index 569b64945..dc8b358c2 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -927,13 +927,13 @@ int processMultibulkBuffer(redisClient *c) {
if (ll >= REDIS_MBULK_BIG_ARG) {
/* 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 optimized object creation
+ * boundary so that we can optimize object creation
* avoiding a large copy of data. */
c->querybuf = sdsrange(c->querybuf,pos,-1);
pos = 0;
/* Hint the sds library about the amount of bytes this string is
* going to contain. */
- c->querybuf = sdsMakeRoomFor(c->querybuf,ll+2);
+ c->querybuf = sdsMakeRoomFor(c->querybuf,ll+2-sdslen(c->querybuf));
}
c->bulklen = ll;
}