Hello,
There is a bug in sh_eval() function that may cause ksh to crash due to double
free() after sourcing multiple files. I am providing a patch to fix this bug.
Steps to reproduce :
> cat functions.ksh
#!/bin/ksh
function f1
{
echo "f1"
}
function f2
{
if [[ $1 -eq 1 ]]: then
echo "f2"
fi
}
function f3
{
[[ 1 = 1 ]] && set -x
}
> cat sub1.ksh
#!/bin/ksh
. ./functions.ksh
echo "sub1" > ./tmp.out
> cat main.ksh
#!/bin/ksh
. ./sub1.ksh
> ksh main.ksh
main.ksh[2]: .[3]: .: syntax error at line 10: `]]:' unexpected
Segmentation fault (core dumped)
--
--
Siteshwar Vashisht
diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c
index 1ba7347..ab745d4 100644
--- a/src/cmd/ksh93/sh/xec.c
+++ b/src/cmd/ksh93/sh/xec.c
@@ -640,7 +640,11 @@ int sh_eval(register Sfio_t *iop, int mode)
if(lineno)
shp->inlineno = lineno;
if(io_save)
+ {
sfclose(io_save);
+ io_save = 0;
+ }
+
sh_freeup(shp);
shp->st.staklist = saveslp;
shp->fn_reset = 0;
--
2.9.3
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers