summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-11-25 14:48:30 +0100
committerantirez <antirez@gmail.com>2014-11-25 14:48:30 +0100
commita8f9a989a78601339c6ab7a72ebd925143f3cf22 (patch)
tree16e480d9661802748b5d0a6cb3e6f87f65376254
parent8a09e129060435034d75d487e796ef6be8f6e246 (diff)
downloadredis-a8f9a989a78601339c6ab7a72ebd925143f3cf22.tar.gz
Avoid valgrind memory leak false positive in processInlineBuffer().
zmalloc(0) cauesd to actually trigger a non-zero allocation since with standard libc malloc we have our own zmalloc header for memory tracking, but at the same time the returned pointer is at the end of the block and not in the middle. This triggers a false positive when testing with valgrind. When the inline protocol args count is 0, we now avoid reallocating c->argv, preventing the issue to happen.
-rw-r--r--src/networking.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/networking.c b/src/networking.c
index f10a1c5e2..7af889d53 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -926,8 +926,10 @@ int processInlineBuffer(redisClient *c) {
sdsrange(c->querybuf,querylen+2,-1);
/* Setup argv array on client structure */
- if (c->argv) zfree(c->argv);
- c->argv = zmalloc(sizeof(robj*)*argc);
+ if (argc) {
+ if (c->argv) zfree(c->argv);
+ c->argv = zmalloc(sizeof(robj*)*argc);
+ }
/* Create redis objects for all arguments. */
for (c->argc = 0, j = 0; j < argc; j++) {