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

Re: SEGV with alias\



On Thu, 23 Jul 2015 19:33:51 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jul 23,  3:18pm, Bart Schaefer wrote:
> } Subject: Re: SEGV with alias\
> }
> } On Thu, Jul 23, 2015 at 2:52 PM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> } > [CCing reporter of the recent ihungetc() issue]
> } >
> } > Typing <l><s><Backslash><Enter><Enter> may segfault if 'ls' is aliased.
> } 
> 
> It doesn't crash any more, but with debug enabled it prints
>     Warning: backing up wrong character.
> forever.

I can stop this cleanly, but I still don't know what the code chunk is
doing.

pws

diff --git a/Src/hist.c b/Src/hist.c
index cf224cb..75e809c 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -906,7 +906,8 @@ ihungetc(int c)
     while (!lexstop && !errflag) {
 	if (hptr[-1] != (char) c && stophist < 4 &&
 	    hptr > chline + 1 && hptr[-1] == '\n' && hptr[-2] == '\\' &&
-	    !(histactive & HA_UNGET)) {
+	    !(histactive & HA_UNGET) &&
+	    (inbufflags & (INP_ALIAS|INP_HIST)) != INP_ALIAS) {
 	    histactive |= HA_UNGET;
 	    hungetc('\n');
 	    hungetc('\\');



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