Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Allocation inconsistency in glob.c
- X-seq: zsh-workers 34965
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: Allocation inconsistency in glob.c
- Date: Sat, 25 Apr 2015 12:38:32 -0700
- 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
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);
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author