Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Valgrind automatic tests, ran for almost every Zsh test and zredis
- X-seq: zsh-workers 41317
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Valgrind automatic tests, ran for almost every Zsh test and zredis
- Date: Sun, 18 Jun 2017 09:24:18 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-transfer-encoding; bh=cb262Ztl3DO7VAv3h5NP61RbwtrsxBDoifJNnajQrGc=; b=bw3BEY7ahwBRvrKdTGq6m+juLT9PXmE3xbwto3DSwQHsWX0DoJFOyGE56JAuzruSqY h0Yxb8KcMsw1fzELxYlzeWhl9Gmtb8PHyQhV0NO3mR0tLcPui5KzvH2UQDmHfk9mTsHX BEVjj+5TX9QJr1N3DZ9UHm4N9anVL4oYjBphXMZsUONyrg01R1eZrJNGJ5+E0r/Ubpcu XnoocHz9wrBjqf8mrhQNtHDggsZTA9JVwgcFbrVbtWb4GuLH1ig0IzOrn+CgXD7CUwfW fu4vizKfyqdpFH/BcRSGIysormrd77QbXv7NJCsQIwhDLp58LS5khNHhqQalztTn1ucK c8Og==
- In-reply-to: <etPan.59466176.7b5dcfbf.63ea@zdharma.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <etPan.5943f5c1.6b8b4567.367a@MacMini.local> <170616220824.ZM28272@torch.brasslantern.com> <etPan.59466176.7b5dcfbf.63ea@zdharma.org>
On Jun 18, 1:18pm, Sebastian Gniazdowski wrote:
}
} Today I wanted to catch something. The bicat() usage seems to leak
} what getoutputfile() returns:
}
} - that function always calls:Â gettempname(NULL, 0), and the 0 == zalloc()
} memory
} - in stringsubst(), after memcpy(), result of getoutputfile() is unused,
} free to release
}
} Attached is a patch with fix for this, it removes the Valgrind error.
Hmm, looking more carefully at this, the problem actually seems to be that
getoutputfile() doesn't need to pass 0 to gettempname() any longer. There
used to be a direct call to zaddlinknode() in getoutputfile(), which needed
a zalloc() string, but that was replaced by addfilelist() which does its own
internal ztrdup().
So the fix is a whole lot simpler:
diff --git a/Src/exec.c b/Src/exec.c
index debb0ae..0a96879 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4570,7 +4570,7 @@ getoutputfile(char *cmd, char **eptr)
}
if (!(prog = parsecmd(cmd, eptr)))
return NULL;
- if (!(nam = gettempname(NULL, 0)))
+ if (!(nam = gettempname(NULL, 1)))
return NULL;
if ((s = simple_redir_name(prog, REDIR_HERESTR))) {
@@ -4601,7 +4601,7 @@ getoutputfile(char *cmd, char **eptr)
suffix = dyncat(nam, unmeta(suffix));
if (link(nam, suffix) == 0) {
addfilelist(nam, 0);
- nam = ztrdup(suffix);
+ nam = suffix;
}
}
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author