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

Re: Crash on tab completion



On Mon, 5 Sep 2016 10:18:57 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Mon, Sep 5, 2016 at 3:42 AM, Patrick Hilhorst
> <patrickhilhorst97@xxxxxxxxx> wrote:
> > alias cpp_check="clang-tidy
> > -checks=\"-*,cppcoreguidelines-*,clang-analyzer-*,misc-*,modernize-*,performance-*,readability-*"
>
> % cpp_check  zle_tricky.c:658: BUG: 0 <= wb (-86) <= zlemetacs (9) <=
> we (9) is not true!
> BUG: substring ends in the middle of a metachar in ztrsub()
>
> Seems to be because wb is computed with the alias
> expanded, but then the alias is unwound before trying to update the
> command line.

Yes, it's the setting of wordbeg in gettok() which makes it a large
number, presumably from the aliased version, whereas when wordebg is
assigned back as difference against zlemetall, the corresponding line
length, that'ss short because it isn't.  So wb is off the start of the
string and mayhem results.

I wonder if the answer to this particular question is as simple as the
following?  This same test is used elswhere in lex.c.

I'm not that worried about making this completion completely sane, more
about fixing the crash and associated index problems.

pws

diff --git a/Src/lex.c b/Src/lex.c
index 6b20e14..e0935bf 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -613,7 +613,7 @@ gettok(void)
     if (lexstop)
 	return (errflag) ? LEXERR : ENDINPUT;
     isfirstln = 0;
-    if ((lexflags & LEXFLAGS_ZLE))
+    if ((lexflags & LEXFLAGS_ZLE) && !(inbufflags & INP_ALIAS))
 	wordbeg = inbufct - (qbang && c == bangchar);
     hwbegin(-1-(qbang && c == bangchar));
     /* word includes the last character read and possibly \ before ! */



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