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

Core dump on completion after `for'

% ./zsh -f
% for f in <TAB>zsh: segmentation fault (core dumped)  ./zsh -f

It's at the first sprintf in the following in get_comp_string().  tok is
51, which is FOR, which is out of range for tokstrings, which only
handles tokens looking like punctuation.

	if (inredir) {
            rdstr = rdstrbuf;
            if (tokfd >= 0)
                sprintf(rdop, "%d%s", tokfd, tokstrings[tok]);
                strcpy(rdop, tokstrings[tok]);
            strcpy(rdstr, rdop);

We've got to this branch because redir is set for special commands which
take lists in ctxtlex():

    if (IS_REDIROP(tok) || tok == FOR || tok == FOREACH || tok == SELECT) {
	inredir = 1;

so there are two ways to handle it:  make these three tokens special
cases of redirections, or simply ignore the inredir flag for them.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070

The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
If you received this in error, please contact the sender and 
delete the material from any computer.

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