Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Segmentation fault immediately after 'unset PATH'



On Thu, 2019-07-11 at 11:48 +0100, Peter Stephenson wrote:
> diff --git a/Src/params.c b/Src/params.c
> index 1859c7c12..95181f533 100644
> --- a/Src/params.c
> +++ b/Src/params.c
> @@ -3617,10 +3617,18 @@ unsetparam_pm(Param pm, int altflag, int exp)
>  	altpm = (Param) paramtab->getnode(paramtab, altremove);
>  	/* tied parameters are at the same local level as each other */
>  	oldpm = NULL;
> -	while (altpm && altpm->level > pm->level) {
> -	    /* param under alternate name hidden by a local */
> -	    oldpm = altpm;
> -	    altpm = altpm->old;
> +	/*
> +	 * Look for param under alternate name hidden by a local.
> +	 * If this parameter is special, however, the visible
> +	 * parameter is the special and the hidden one is keeping
> +	 * and old value --- we just mark the visible one as unset.
> +	 */
> +	if (altpm && !(altpm->node.flags & PM_SPECIAL))
> +	{
> +	    while (altpm && altpm->level > pm->level) {
> +		oldpm = altpm;
> +		altpm = altpm->old;
> +	    }
>  	}
>  	if (altpm) {
>  	    if (oldpm && !altpm->level) {

Hmm... can that loop I've "if"ed out ever be right?  It's meaning we're
unsetting the saved version of a parameter, not the visible one.  That
looks pretty fishy at any time.

pws



Messages sorted by: Reverse Date, Date, Thread, Author