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.
This commit is contained in:
antirez 2014-11-25 14:48:30 +01:00
parent 3765a5d9ba
commit f2876f6cf7

View File

@ -926,8 +926,10 @@ int processInlineBuffer(redisClient *c) {
sdsrange(c->querybuf,querylen+2,-1); sdsrange(c->querybuf,querylen+2,-1);
/* Setup argv array on client structure */ /* Setup argv array on client structure */
if (c->argv) zfree(c->argv); if (argc) {
c->argv = zmalloc(sizeof(robj*)*argc); if (c->argv) zfree(c->argv);
c->argv = zmalloc(sizeof(robj*)*argc);
}
/* Create redis objects for all arguments. */ /* Create redis objects for all arguments. */
for (c->argc = 0, j = 0; j < argc; j++) { for (c->argc = 0, j = 0; j < argc; j++) {