From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15157 invoked by alias); 25 Apr 2015 19:38:51 -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: 34965 Received: (qmail 21797 invoked from network); 25 Apr 2015 19:38:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:to:subject:mime-version :content-type; bh=ejf+xLgDfXpzc8Jli/6H2U4fy3CsNv6QQhSdZ7DqCsM=; b=PnxP9NS07NJpZvOMQspe52PlL1JEUxbeJ2jGbXoLEnI2nD2W/yaNKQxzDpF4qXIWag Et7+vZaU1VxPPFe5ZqsQY+1nBMk7sYbZLcJzeGs2ivVcGmXgmFKdm0rStwLZW8SntRCN RmrU7nxElJS83v8bP3fXIsrFxCg2ItL4rEkO5L2R+z0Sq45W4OxSr4JC/MmwVrtCRnJi j9f/EUi2S496u2LIJD94o7xz+nRvvQ4aCMYmOql/j/1J55y3lSV8yLhfusbuM2mWW+ND n2QMh17yITRSqdB201Zu+16xTEyj+ag/nlaeSshrPinprK4A6oXdhb9YEJmdAhr9Fv5d BdVQ== X-Gm-Message-State: ALoCoQkqP6B/fyUYZs8LBLa7iYvqlY15WW1BM7JgMUf0+wDUDUcBkf/NXLBfIaB89ejadtt46C/E X-Received: by 10.60.123.100 with SMTP id lz4mr3787641oeb.86.1429990714229; Sat, 25 Apr 2015 12:38:34 -0700 (PDT) From: Bart Schaefer Message-Id: <150425123832.ZM582@torch.brasslantern.com> Date: Sat, 25 Apr 2015 12:38:32 -0700 X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: PATCH: Allocation inconsistency in glob.c MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Back in workers/32931 I observed that there seemed to be some inconsistency about the way zalloc and realloc were used in glob.c The patch below addresses this. diff --git a/Src/glob.c b/Src/glob.c index ad29223..057d44a 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -437,7 +437,7 @@ insert(char *s, int checked) matchptr++; if (++matchct == matchsz) { - matchbuf = (Gmatch )realloc((char *)matchbuf, + matchbuf = (Gmatch)zrealloc((char *)matchbuf, sizeof(struct gmatch) * (matchsz *= 2)); matchptr = matchbuf + matchct; @@ -1818,7 +1818,7 @@ zglob(LinkList list, LinkNode np, int nountok) badcshglob |= 1; /* at least one cmd. line expansion failed */ } else if (isset(NOMATCH)) { zerr("no matches found: %s", ostr); - free(matchbuf); + zfree(matchbuf, 0); restore_globstate(saved); return; } else { @@ -1923,7 +1923,7 @@ zglob(LinkList list, LinkNode np, int nountok) } else if (!badcshglob && !isset(NOMATCH) && matchct == 1) { insert_glob_match(list, node, (--matchptr)->name); } - free(matchbuf); + zfree(matchbuf, 0); restore_globstate(saved); }