ksh/ksh93-ifs.dif
2010-10-27 12:15:33 +00:00

42 lines
1.1 KiB
Plaintext

---
src/cmd/ksh93/sh/init.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2010-10-08 12:43:27.123926224 +0000
@@ -456,6 +456,8 @@ static void put_cdpath(register Namval_t
}
#endif /* _hdr_locale */
+static const void* ifs_hdr;
+
/* Trap for IFS assignment and invalidates state table */
static void put_ifs(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
{
@@ -464,9 +466,14 @@ static void put_ifs(register Namval_t* n
ip->ifsnp = 0;
if(!val)
{
- fp = nv_stack(np, NIL(Namfun_t*));
- if(fp && !fp->nofree)
- free((void*)fp);
+ Namfun_t *xp = nv_stack(np, NIL(Namfun_t*));
+ if(xp)
+ {
+ if(xp == ifs_hdr)
+ xp->nofree = 1;
+ if(xp->nofree == 0)
+ free((void*)xp);
+ }
}
if(val != np->nvalue.cp)
nv_putv(np, val, flags, fp);
@@ -1597,6 +1604,7 @@ static Init_t *nv_init(Shell_t *shp)
ip->LANG_init.nofree = 1;
#endif /* _hdr_locale */
nv_stack(IFSNOD, &ip->IFS_init.hdr);
+ ifs_hdr = (IFSNOD)->nvfun;
nv_stack(PATHNOD, &ip->PATH_init);
nv_stack(FPATHNOD, &ip->FPATH_init);
nv_stack(CDPNOD, &ip->CDPATH_init);