From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12093 invoked by alias); 18 Jun 2017 16:23:42 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41317 Received: (qmail 27661 invoked from network); 18 Jun 2017 16:23:42 -0000 X-Qmail-Scanner-Diagnostics: from mail-vk0-f53.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.213.53):SA:0(-0.0/5.0):. Processed in 1.570718 secs); 18 Jun 2017 16:23:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.213.53 as permitted sender) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-transfer-encoding; bh=cb262Ztl3DO7VAv3h5NP61RbwtrsxBDoifJNnajQrGc=; b=Flmw4d1t1Tb0664remcHXf3xiEBI97lfmf/aOP8dy4nIYk4bk3/Oj3v078aEnhcOUh YoVeeNfRYmr/tiqKhZP7nimp57Gk+2ydn06oHnE0qgI3hJR/h84vromTmI7O6bgVdbOM cpXfVAcVu/sA1Wv1LJTvHt+JAZkJq1/NYLOkhkmdjq2cc8onX/EM0AWXA+2ig0yPCTkn gZz6osEky7zIX29eHNvA12G+/9OAa7ozXbLQufSF8exnW5mwIBAskUN5J+4fZE2AD1YY MlxAol67tyzReLs1XMbsR4wlpOCRRsxBwJ74OZ1tR3+PGZ/depeXDxJfxmERC+Dg4MeR HWtg== X-Gm-Message-State: AKS2vOxXDcZxiAnLFVL8tSjamSLjElwe40DkAORnbbWA4OBL2nmb25Sv BgTUKkDmljW39OrOvDA= X-Received: by 10.31.219.71 with SMTP id s68mr9810454vkg.102.1497803011252; Sun, 18 Jun 2017 09:23:31 -0700 (PDT) From: Bart Schaefer Message-Id: <170618092418.ZM13922@torch.brasslantern.com> Date: Sun, 18 Jun 2017 09:24:18 -0700 In-Reply-To: Comments: In reply to Sebastian Gniazdowski "Re: Valgrind automatic tests, ran for almost every Zsh test and zredis" (Jun 18, 1:18pm) References: <170616220824.ZM28272@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Valgrind automatic tests, ran for almost every Zsh test and zredis MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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:=C2=A0gettempname(NULL, 0), and the 0 =3D=3D= zalloc() } memory } - in stringsubst(), after memcpy(), result of getoutputfile() is unused, } free to release }=20 } 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 =3D parsecmd(cmd, eptr))) return NULL; - if (!(nam =3D gettempname(NULL, 0))) + if (!(nam =3D gettempname(NULL, 1))) return NULL; =20 if ((s =3D simple_redir_name(prog, REDIR_HERESTR))) { @@ -4601,7 +4601,7 @@ getoutputfile(char *cmd, char **eptr) suffix =3D dyncat(nam, unmeta(suffix)); if (link(nam, suffix) =3D=3D 0) { addfilelist(nam, 0); - nam =3D ztrdup(suffix); + nam =3D suffix; } } }