From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29439 invoked by alias); 23 Sep 2015 21:55:00 -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: 36603 Received: (qmail 15363 invoked from network); 23 Sep 2015 21:54:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=0oed0oRPKdIKszB8StMoPt7jkiGf5RW1O0M3G5fBhwo=; b=aMD43fBcqlzNlhfk5x4rqojQaRzyZX7ymKq9qpIRtxBN4Aw3BHNXFRvcSYCTfBG+se AZx5DKiYmKdrBl9u3mV+38pM+CRTgCJvbAYTjvbqdXu3jxoCYABwY64xSz11fpSWZS6h x4gQgZXZhEdBlMLNjVCTnNucirmLff5peqr+K+FxNnNQx3wijUJhpiNc41yAS39N6q7F h9btVfkn1ow7amIFzI35bcFBfIr1E1mXAmUJqM1RDq1WNEuCpdCO6bA7UATm1e4NMAQu zmpOS0KSbhkihTGMHT/bspkKaU3Kn/GRHEo1/WMAps7psVTUYhgL7CN7i1qZ3jlA/frW 2cIQ== X-Received: by 10.194.246.102 with SMTP id xv6mr35881112wjc.58.1443045295133; Wed, 23 Sep 2015 14:54:55 -0700 (PDT) From: Mikael Magnusson To: zsh-workers@zsh.org Subject: PATCH: Fix leak during Y shortcircuit glob qualifier Date: Wed, 23 Sep 2015 23:54:50 +0200 Message-Id: <1443045290-26615-1-git-send-email-mikachu@gmail.com> X-Mailer: git-send-email 2.5.0 The closedir(lock) is the leak I actually did see in usage, I have no idea if the other part is needed/harmful though. I'll commit just the closedir if nobody has any opinions. --- Src/glob.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Src/glob.c b/Src/glob.c index 4db6570..8fbefc9 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -534,7 +534,7 @@ scanner(Complist q, int shortcircuit) if (!closure || !statfullpath("", NULL, 1)) { scanner((q->closure) ? q : q->next, shortcircuit); if (shortcircuit && shortcircuit == matchct) - return; + goto freedir; } pathbuf[pathpos = oppos] = '\0'; } @@ -544,7 +544,7 @@ scanner(Complist q, int shortcircuit) str = dupstrpfx(str, l); insert(str, 0); if (shortcircuit && shortcircuit == matchct) - return; + goto freedir; } } else { /* Do pattern matching on current path section. */ @@ -635,8 +635,10 @@ scanner(Complist q, int shortcircuit) } else { /* if the last filename component, just add it */ insert(fn, 1); - if (shortcircuit && shortcircuit == matchct) - return; + if (shortcircuit && shortcircuit == matchct) { + closedir(lock); + goto freedir; + } } } } @@ -659,6 +661,7 @@ scanner(Complist q, int shortcircuit) hrealloc(subdirs, subdirlen, 0); } } +freedir: if (pbcwdsav < pathbufcwd) { if (restoredir(&ds)) zerr("current directory lost during glob"); -- 2.5.0