zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Allocation inconsistency in glob.c
@ 2015-04-25 19:38 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2015-04-25 19:38 UTC (permalink / raw)
  To: zsh-workers

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);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-25 19:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-25 19:38 PATCH: Allocation inconsistency in glob.c Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).