Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The following set of commands caused ksh to crash: $ unalias history; unalias r Memory fault When ksh is compiled with -D_std_malloc, the crash always occurs when the 'r' alias is removed with 'unalias r', although with vmalloc 'unalias history' must be run first for the crash to occur. With the native malloc, the crash message is also different: $ unalias history; unalias r free(): invalid pointer Abort This crash happens because when an alias is unset, _nv_unset removes the NV_NOFREE flag which results in an invalid use of free(3) as nv_isattr no longer detects NV_NOFREE afterward. The history and r aliases shouldn't be freed from memory by nv_delete because those aliases are given the NV_NOFREE attribute. src/cmd/ksh93/bltins/typeset.c: - Save the state of NV_NOFREE for aliases to fix the crash caused by 'unalias r'. src/cmd/ksh93/tests/alias.sh: - Use unalias on both history and r to check for the crash. 'unalias -a' can't be used to replicate the crash. Co-authored-by: Martijn Dekker <martijn@inlv.org>
- Loading branch information