From f0cc7da47f5b8831b15a7396f1f98ffe5f23c81a Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Wed, 12 Jun 2013 13:31:22 +0200 Subject: [PATCH] fix memory leak --- ksh-20120801-memlik.patch | 37 +++++++++++++++++++++++++++++++++++++ ksh.spec | 9 +++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 ksh-20120801-memlik.patch diff --git a/ksh-20120801-memlik.patch b/ksh-20120801-memlik.patch new file mode 100644 index 0000000..31f1eb9 --- /dev/null +++ b/ksh-20120801-memlik.patch @@ -0,0 +1,37 @@ +diff -up ksh-20120801/src/cmd/ksh93/sh/array.c.memlik ksh-20120801/src/cmd/ksh93/sh/array.c +--- ksh-20120801/src/cmd/ksh93/sh/array.c.memlik 2012-06-07 00:00:42.000000000 +0200 ++++ ksh-20120801/src/cmd/ksh93/sh/array.c 2013-06-11 16:52:47.557123973 +0200 +@@ -1701,7 +1701,11 @@ void *nv_associative(register Namval_t * + ap->header.scope = 0; + } + else +- dtclose(ap->header.table); ++ { ++ if((ap->header.nelem&ARRAY_MASK)==0 && (ap->cur=nv_search("0",ap->header.table,0))) ++ nv_associative(np,(char*)0,NV_ADELETE); ++ dtclose(ap->header.table); ++ } + return((void*)ap); + case NV_ANEXT: + if(!ap->pos) +diff -up ksh-20120801/src/cmd/ksh93/sh/name.c.memlik ksh-20120801/src/cmd/ksh93/sh/name.c +--- ksh-20120801/src/cmd/ksh93/sh/name.c.memlik 2012-07-23 18:21:57.000000000 +0200 ++++ ksh-20120801/src/cmd/ksh93/sh/name.c 2013-06-11 16:19:41.036648218 +0200 +@@ -2465,6 +2465,8 @@ static void table_unset(Shell_t *shp, re + } + } + npnext = (Namval_t*)dtnext(root,np); ++ if(nv_arrayptr(np)) ++ nv_putsub(np,NIL(char*),ARRAY_SCAN); + _nv_unset(np,flags); + nv_delete(np,root,0); + } +@@ -3326,7 +3328,7 @@ int nv_rename(register Namval_t *np, int + shp->last_root = last_root; + if(flags&NV_MOVE) + { +- if(arraynp && !nv_isattr(np,NV_MINIMAL) && (mp=(Namval_t*)np->nvenv) && (ap=nv_arrayptr(mp))) ++ if(arraynp && !nv_isattr(np,NV_MINIMAL) && (mp=(Namval_t*)np->nvenv) && (ap=nv_arrayptr(mp)) && !ap->fun) + ap->nelem++; + } + if((nv_arrayptr(nr) && !arraynr) || nv_isvtree(nr)) diff --git a/ksh.spec b/ksh.spec index 4222e2d..05b44bf 100644 --- a/ksh.spec +++ b/ksh.spec @@ -6,7 +6,7 @@ URL: http://www.kornshell.com/ Group: System Environment/Shells License: EPL Version: 20120801 -Release: 9%{?dist} +Release: 10%{?dist} Source0: http://www.research.att.com/~gsf/download/tgz/ast-ksh.%{releasedate}.tgz Source1: http://www.research.att.com/~gsf/download/tgz/INIT.%{releasedate}.tgz Source2: kshcomp.conf @@ -26,6 +26,7 @@ Patch5: ksh-20120801-tabfix.patch Patch6: ksh-20120801-cdfix2.patch Patch7: ksh-20130214-fixkill.patch Patch8: ksh-20120801-kshmfix.patch +Patch9: ksh-20120801-memlik.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Conflicts: pdksh @@ -53,6 +54,7 @@ with "sh" (the Bourne Shell). %patch6 -p1 -b .cdfix2 %patch7 -p1 -b .fixkill %patch8 -p1 -b .kshmfix +%patch9 -p1 -b .memlik #/dev/fd test does not work because of mock sed -i 's|ls /dev/fd|ls /proc/self/fd|' src/cmd/ksh93/features/options @@ -82,7 +84,7 @@ install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/kshrc install -D -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/binfmt.d/kshcomp.conf %check -[ -f ./skipcheck -o -f ./../skipcheck] && exit 0 ||: +[ -f ./skipcheck -o -f ./../skipcheck ] && exit 0 ||: %if 0%{?rhel} > 6 %ifarch s390 exit 0 @@ -147,6 +149,9 @@ fi rm -rf $RPM_BUILD_ROOT %changelog +* Wed Jun 12 2013 Michal Hlavinka - 20120801-10 +- fix memory leak + * Mon Jun 10 2013 Michal Hlavinka - 20120801-9 - monitor mode in scripts wasn't working