diff --git a/src/cmd/ksh93/sh/nvdisc.c b/src/cmd/ksh93/sh/nvdisc.c index 0e5b53b0e..38717b834 100644 --- a/src/cmd/ksh93/sh/nvdisc.c +++ b/src/cmd/ksh93/sh/nvdisc.c @@ -367,7 +367,7 @@ static void assign(Namval_t *np,const char* val,int flags,Namfun_t *handle) done: if(bp== &block) block_done(bp); - if(nq && nq->nvalue.rp->running==1) + if(nq && nq->nvalue.rp && nq->nvalue.rp->running==1) { nq->nvalue.rp->running=0; _nv_unset(nq,0); diff --git a/src/cmd/ksh93/tests/variables.sh b/src/cmd/ksh93/tests/variables.sh index 0e496a2c3..5c48b2113 100755 --- a/src/cmd/ksh93/tests/variables.sh +++ b/src/cmd/ksh93/tests/variables.sh @@ -1369,5 +1369,13 @@ got=$("$SHELL" -c $'foo=baz; foo+=_foo "$SHELL" -c \'print $foo\'; print $foo') [[ $exp == "$got" ]] || err_exit "using the += operator for invocation-local assignments changes variables outside of the invocation-local scope" \ "(expected $(printf %q "$exp"), got $(printf %q "$got"))" +# ====== +# Crash when setting attribute after getn (numeric get) discipline +# https://github.com/ksh93/ksh/issues/435#issuecomment-1148813866 +got=$("$SHELL" -c 'foo.getn() { .sh.value=2.3*4.5; }; typeset -F2 foo; typeset -p foo' 2>&1) +exp='typeset -F 2 foo=10.35' +[[ $got == "$exp" ]] || err_exit "Setting attribute after setting getn discipline fails" \ + "(expected $(printf %q "$exp"), got $(printf %q "$got"))" + # ====== exit $((Errors<125?Errors:125))