1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix arrays.sh test failure under ASan (#411)

This backports a ksh2020 fix for an ASan heap-use-after-free error in
arrays.sh. The arrays regression tests were failing under ASan because
the ap pointer was used after the memory allocated to it was freed by
_nv_unset(). ksh2020 commit:
f1e5119e31
This commit is contained in:
Johnothan King 2022-01-02 00:08:33 -08:00 committed by Martijn Dekker
parent 997f0e9dd8
commit 7c7fde75c8

View file

@ -519,8 +519,9 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
}
else if(((np->nvalue.cp && np->nvalue.cp!=Empty)||nv_isvtree(np)|| nv_arrayptr(np)) && !nv_type(np))
{
_nv_unset(np,NV_EXPORT);
if(ap && ap->fun)
int was_assoc_array = ap && ap->fun;
_nv_unset(np,NV_EXPORT); /* this can free ap */
if(was_assoc_array)
nv_setarray(np,nv_associative);
}