mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 19:52:20 +00:00
Fix crash on setting attribute to variable with getn discipline
The 'getn' discipline is experimental and undocumented, the only mention of it being an old mailing list post from David Korn: https://www.mail-archive.com/ast-users@research.att.com/msg00601.html But it still should not crash. $ LC_NUMERIC=C ENV=/./dev/null arch/*/bin/ksh $ foo.getn() { .sh.value=2.3*4.5; } $ typeset -F foo Memory fault src/cmd/ksh93/sh/nvdisc.c: assign(): - Check that the nvalue union has a non-NULL pointer before using it. Progresses: https://github.com/ksh93/ksh/issues/435
This commit is contained in:
parent
9da0887e54
commit
2a43cbc3f6
2 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue