Re: csh: memory leak in setDolp()
BTW the leak happens when a pattern in variable modifier s/// is not found. $ set a="test" $ echo $a:s/badpattern// test Any objections if I commit this? On Thu, Sep 20, 2018 at 12:30:05PM +0800, Michael Mikonos wrote: > Hello, > > In setDolp() pointers cp and dp initially point to the same > copied string, but later dp can become NULL if Strstr() finds > no match. The copied string is not freed in this case. > NetBSD added this fix in their dol.c revision 1.23 (2006). > OK? > > - Michael > > > Index: dol.c > === > RCS file: /cvs/src/bin/csh/dol.c,v > retrieving revision 1.24 > diff -u -p -u -r1.24 dol.c > --- dol.c 18 Sep 2018 06:56:09 - 1.24 > +++ dol.c 20 Sep 2018 04:14:37 - > @@ -766,8 +766,10 @@ setDolp(Char *cp) > addla(dp); > free(dp); > } > -else > +else { > addla(cp); > + free(cp); > +} > > dolp = STRNULL; > if (seterr)
Re: csh: memory leak in setDolp()
On Thu, 20 Sep 2018 12:30:05 +0800, Michael Mikonos wrote: > In setDolp() pointers cp and dp initially point to the same > copied string, but later dp can become NULL if Strstr() finds > no match. The copied string is not freed in this case. > NetBSD added this fix in their dol.c revision 1.23 (2006). OK millert@ - todd
csh: memory leak in setDolp()
Hello, In setDolp() pointers cp and dp initially point to the same copied string, but later dp can become NULL if Strstr() finds no match. The copied string is not freed in this case. NetBSD added this fix in their dol.c revision 1.23 (2006). OK? - Michael Index: dol.c === RCS file: /cvs/src/bin/csh/dol.c,v retrieving revision 1.24 diff -u -p -u -r1.24 dol.c --- dol.c 18 Sep 2018 06:56:09 - 1.24 +++ dol.c 20 Sep 2018 04:14:37 - @@ -766,8 +766,10 @@ setDolp(Char *cp) addla(dp); free(dp); } -else +else { addla(cp); + free(cp); +} dolp = STRNULL; if (seterr)