components/ksh93/patches/205-17851169.patch
author Norm Jacobs <Norm.Jacobs@Oracle.COM>
Mon, 27 Apr 2015 10:19:50 -0500
changeset 4196 d697072a92f5
parent 1705 components/ksh93/patches/17851169.patch@f76a8a4838a4
child 4268 d723f8ed85fe
permissions -rw-r--r--
19782029 userland should be able to build from SCM repositories

http://lists.research.att.com/pipermail/ast-developers/2014q1/003809.html
---
--- a/src/cmd/ksh93/sh/subshell.c
+++ b/src/cmd/ksh93/sh/subshell.c
@@ -234,15 +234,22 @@ Namval_t *sh_assignok(register Namval_t *np,int add)
 {
 	register Namval_t	*mp;
 	register struct Link	*lp;
-	register struct subshell *sp = (struct subshell*)subshell_data;
-	Shell_t			*shp = sp->shp;
-	Dt_t			*dp= shp->var_tree;
+	register struct subshell *sp;
+	Shell_t			*shp;
+	Dt_t			*dp;
 	Namval_t		*mpnext;
 	Namarr_t		*ap;
 	int			save;
+
+        sp = (struct subshell*)subshell_data;
+
 	/* don't bother with this */
-	if(!sp->shpwd || np==SH_LEVELNOD || np==L_ARGNOD || np==SH_SUBSCRNOD || np==SH_NAMENOD)
+	if(!sp || !sp->shpwd || np==SH_LEVELNOD || np==L_ARGNOD || np==SH_SUBSCRNOD || np==SH_NAMENOD)
 		return(np);
+
+	shp = sp->shp;
+	dp = shp->var_tree;
+
 	if((ap=nv_arrayptr(np)) && (mp=nv_opensub(np)))
 	{
 		shp->last_root = ap->table;