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

Re: ${(z)} split of unmatched, doubled ((



Bart Schaefer wrote on Sun, Sep 27, 2015 at 17:59:06 -0700:
> So perhaps this:
> 
> +++ b/Src/lex.c
> @@ -785,6 +785,8 @@ gettok(void)
>  		default:
> +		    if (lexflags & LEXFLAGS_ACTIVE)
> +			tokstr = dyncat("((", tokstr);
>  		    return LEXERR;

LGTM: I've tested it both manually and under zsh-syntax-highlighting,
and it's an improvement in both cases.

> 
> It might be prudent to also test that tokstr != NULL there, but I have
> not found a sample input where that occurs.

The failure mode when tokstr is NULL is calling strlen/strcpy on a NULL
argument, which is formally undefined behaviour and practically will
probably just segfault.  If we can't prove that tokstr is always
non-NULL, I would vote to test it for NULL before using it.  

Thanks,

Daniel



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