On Fri, Oct 08, 2010 at 11:46:28AM +0200, Werner Fink wrote:
> Hi,
>
> just take this as simple test
>
> ----------------------------------------------------------------------
> #!/bin/ksh
>
> echo ">$IFS<"
>
> function crash
> {
> typeset L_FILE
> typeset L_VALIDATION
> typeset L_VARIABLE
> typeset L_MOD IFS
>
> OS=$(uname)
> }
>
> crash
>
> echo ">$IFS<"
>
> function crash2
> {
> typeset IFS
> true
> unset IFS
> echo a b c | while read x ; do
> echo $x
> done
> }
>
> crash2
>
> echo ">$IFS<"
>
> # end here
> ----------------------------------------------------------------------
>
> shows this:
>
> tmp/ksh> ksh ~/crash.ksh
> Segmentation fault
The patch attached should work around the problem. It seems
that during handling global shell variables the nofree flag
will be missed.
Werner
--
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr
---
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);
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers