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

Re: crashes when setting COLUMNS=0 or 1



On Thursday 2011-06-09 12:36 +0200, Mikael Magnusson output:
:To reproduce, run COLUMNS=0 and type two characters. This code in
:zle_refresh is where it crashes, it looks quite suspicious too.
:
:ZR_memset(p1 + nllen, zr_sp, winw - nllen);
:p1[winw] = zr_zr;
:if (nllen < winw)
:    p1[winw + 1] = zr_zr;
:else
:    p1[winw + 1] = nl[winw + 1];
:
:The code seems to expect nllen to possibly be larger than winw, yet it
:passes winw - nllen to memset as the length? (which is where it
:crashes).

I believe that it's checking if nllen equals winw (which is quite valid),
not that it is larger.  It's been a long time since I looked at this code.

:I can actually get a crash with a 1-char wide window too, by
:just resizing the terminal and typing some characters (This doesn't
:happen right away, needs to fiddle around for a bit, possibly ctrl-a
:and type some more). At first I thought it had to be doublewidth
:characters, but regular ones trigger it too.

Sounds like a different bug.

Old versions of Zsh never let COLUMNS be set to 0 or negative numbers.
It would retain its old value if you tried since it just doesn't make
sense.  This behaviour should be recovered.  Try 

% COLUMNS=-1; echo $COLUMNS
-1
%  (core dumped)

Regards,
Geoff



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