Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: Memory leaks.
- X-seq: zsh-workers 11722
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: Memory leaks.
- Date: Fri, 2 Jun 2000 10:08:27 +0200 (MET DST)
- In-reply-to: Felix Rosencrantz's message of Thu, 1 Jun 2000 23:06:40 -0700 (PDT)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Felix Rosencrantz wrote:
> ...
>
> Memory leak from bin_compadd():
> malloc [rtlib.o]
> zcalloc [mem.c:469]
> parse_cmatcher [complete.c:294]
> bin_compadd [complete.c:580]
> execbuiltin [builtin.c:368]
> execcmd [exec.c:2257]
Oops. parse_cmatcher() should use heap memory, maybe this got confused
when removing useheap.
> Another leak in bin_compadd:
> malloc [rtlib.o]
> zalloc [mem.c:453]
> ztrdup [mem.c:530]
> bin_compadd [complete.c:574]
> execbuiltin [builtin.c:368]
> execcmd [exec.c:2257]
>
> I think this is due to the fact that we do a tricat on complete.c:572, without
> freeing the previous values of mstr.
Right.
> Memory leak from addvars():
> malloc [rtlib.o]
> zalloc [mem.c:453]
> ztrdup [mem.c:530]
> addvars [exec.c:1510]
> execsimple [exec.c:750]
> execlist [exec.c:801]
Hmm. Maybe we get this because some parameter setfn() neither uses nor
frees the string it gets.
> Memory leak out of mkautofn():
> malloc [rtlib.o]
> zalloc [mem.c:453]
> mkautofn [builtin.c:2161]
> bin_functions [builtin.c:2143]
> execbuiltin [builtin.c:368]
> execcmd [exec.c:2257]
I can't see where this comes from. mkautofn() creates the
autofn-program wich is then freed in loadautofn() (or
freeshfuncnode(), with ksh-autoloading).
All these autofn-progs won't be freed at the end, though (together
with many other things).
> ...
>
> Memory leak from memory allocated in permmatches():
> malloc [rtlib.o]
> zcalloc [mem.c:469]
> permmatches [compcore.c:2771]
> get_nmatches [complete.c:1057]
> getstrvalue [params.c:1367]
> getarg [params.c:967]
Whoa. Right.
> Memory leak from set_gmatcher():
> malloc [rtlib.o]
> zcalloc [mem.c:469]
> parse_cmatcher [complete.c:294]
> set_gmatcher [compctl.c:313]
> get_gmatcher [compctl.c:341]
> bin_compctl [compctl.c:1587]
This is the same one as the first.
> (I guess this is still in my startup files...)
Tststs ;-)
Bye
Sven
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.27
diff -u -r1.27 compcore.c
--- Src/Zle/compcore.c 2000/05/31 09:56:12 1.27
+++ Src/Zle/compcore.c 2000/06/02 08:07:26
@@ -2879,6 +2879,7 @@
for (m = g->matches; *m; m++)
freematch(*m, g->nbrbeg, g->nbrend);
+ free(g->matches);
if (g->ylist)
freearray(g->ylist);
Index: Src/Zle/complete.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complete.c,v
retrieving revision 1.10
diff -u -r1.10 complete.c
--- Src/Zle/complete.c 2000/06/02 01:54:33 1.10
+++ Src/Zle/complete.c 2000/06/02 08:07:26
@@ -291,7 +291,7 @@
if (err)
return pcm_err;
- n = (Cmatcher) zcalloc(sizeof(*ret));
+ n = (Cmatcher) hcalloc(sizeof(*ret));
n->next = NULL;
n->flags = fl;
n->line = line;
@@ -568,9 +568,11 @@
return 1;
}
if (dm) {
- if (mstr)
- mstr = tricat(mstr, " ", m);
- else
+ if (mstr) {
+ char *tmp = tricat(mstr, " ", m);
+ zsfree(mstr);
+ mstr = tmp;
+ } else
mstr = ztrdup(m);
m = NULL;
}
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author