103 lines
2.8 KiB
Plaintext
103 lines
2.8 KiB
Plaintext
|
--- src/cmd/ksh93/bltins/misc.c
|
||
|
+++ src/cmd/ksh93/bltins/misc.c 2009-08-04 11:59:27.525901725 +0000
|
||
|
@@ -276,7 +276,11 @@ int b_dot_cmd(register int n,char *ar
|
||
|
shp->st.cmdname = argv[0];
|
||
|
if(np)
|
||
|
shp->st.filename = np->nvalue.rp->fname;
|
||
|
+ if (SH_PATHNAMENOD->nvfun)
|
||
|
+ SH_PATHNAMENOD->nvfun->nofree |= 4;
|
||
|
nv_putval(SH_PATHNAMENOD, shp->st.filename ,NV_NOFREE);
|
||
|
+ if (SH_PATHNAMENOD->nvfun)
|
||
|
+ SH_PATHNAMENOD->nvfun->nofree &= ~4;
|
||
|
shp->posix_fun = 0;
|
||
|
if(np || argv[1])
|
||
|
argsave = sh_argnew(shp,argv,&saveargfor);
|
||
|
--- src/cmd/ksh93/sh/subshell.c
|
||
|
+++ src/cmd/ksh93/sh/subshell.c 2009-08-04 11:57:31.829902225 +0000
|
||
|
@@ -252,7 +252,7 @@ Namval_t *sh_assignok(register Namval_t
|
||
|
Dt_t *dp;
|
||
|
Namval_t *mpnext;
|
||
|
Namarr_t *ap;
|
||
|
- int save;
|
||
|
+ int save, leak;
|
||
|
/* don't bother with this */
|
||
|
if(!sp->shpwd || (nv_isnull(np) && !add))
|
||
|
return(np);
|
||
|
@@ -309,7 +309,18 @@ Namval_t *sh_assignok(register Namval_t
|
||
|
save = shp->subshell;
|
||
|
shp->subshell = 0;
|
||
|
mp->nvname = np->nvname;
|
||
|
+ leak = 0;
|
||
|
+ if (np->nvfun && np->nvfun->nofree&4)
|
||
|
+ {
|
||
|
+ leak = 1;
|
||
|
+ np->nvfun->nofree &= ~4;
|
||
|
+ }
|
||
|
nv_clone(np,mp,(add?(nv_isnull(np)?0:NV_NOFREE)|NV_ARRAY:NV_MOVE));
|
||
|
+ if (leak && mp->nvfun && np->nvfun != mp->nvfun)
|
||
|
+ {
|
||
|
+ free((void*)mp->nvfun);
|
||
|
+ mp->nvfun = np->nvfun;
|
||
|
+ }
|
||
|
shp->subshell = save;
|
||
|
return(np);
|
||
|
}
|
||
|
--- src/cmd/ksh93/sh/xec.c
|
||
|
+++ src/cmd/ksh93/sh/xec.c 2009-08-04 11:58:31.033901866 +0000
|
||
|
@@ -339,6 +339,7 @@ struct Level
|
||
|
Namfun_t hdr;
|
||
|
short maxlevel;
|
||
|
};
|
||
|
+struct Level *leaklp;
|
||
|
|
||
|
/*
|
||
|
* this is for a debugger but it hasn't been tested yet
|
||
|
@@ -352,7 +353,11 @@ static void put_level(Namval_t* np,const
|
||
|
int16_t level, oldlevel = (int16_t)nv_getnum(np);
|
||
|
nv_putv(np,val,flags,fp);
|
||
|
if(!val)
|
||
|
+ {
|
||
|
+ if (np == SH_LEVELNOD)
|
||
|
+ leaklp = (struct Level*)(SH_LEVELNOD->nvfun);
|
||
|
return;
|
||
|
+ }
|
||
|
level = nv_getnum(np);
|
||
|
if(level<0 || level > lp->maxlevel)
|
||
|
{
|
||
|
@@ -374,7 +379,22 @@ static const Namdisc_t level_disc = { s
|
||
|
|
||
|
static struct Level *init_level(int level)
|
||
|
{
|
||
|
- struct Level *lp = newof(NiL,struct Level,1,0);
|
||
|
+ struct Level *lp;
|
||
|
+ if (!leaklp)
|
||
|
+ lp = newof(NiL,struct Level,1,0);
|
||
|
+ else
|
||
|
+ {
|
||
|
+ if (leaklp->hdr.disc)
|
||
|
+ {
|
||
|
+ leaklp->hdr.disc = NIL(const Namdisc_t*);
|
||
|
+ lp = leaklp;
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ free((void*)leaklp);
|
||
|
+ lp = newof(NiL,struct Level,1,0);
|
||
|
+ }
|
||
|
+ }
|
||
|
lp->maxlevel = level;
|
||
|
_nv_unset(SH_LEVELNOD,0);
|
||
|
nv_onattr(SH_LEVELNOD,NV_INT16|NV_NOFREE);
|
||
|
@@ -2689,7 +2709,11 @@ static void sh_funct(Shell_t *shp,Namval
|
||
|
save = argv[-1];
|
||
|
argv[-1] = 0;
|
||
|
shp->st.funname = nv_name(np);
|
||
|
+ if (SH_FUNNAMENOD->nvfun)
|
||
|
+ SH_FUNNAMENOD->nvfun->nofree |= 4;
|
||
|
nv_putval(SH_FUNNAMENOD, nv_name(np),NV_NOFREE);
|
||
|
+ if (SH_FUNNAMENOD->nvfun)
|
||
|
+ SH_FUNNAMENOD->nvfun->nofree &= ~4;
|
||
|
opt_info.index = opt_info.offset = 0;
|
||
|
error_info.errors = 0;
|
||
|
shp->st.loopcnt = 0;
|