From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7248 invoked by alias); 5 Sep 2016 20:33:11 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39185 Received: (qmail 5718 invoked from network); 5 Sep 2016 20:33:11 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-9.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.73):SA:0(-0.0/5.0):. Processed in 0.497347 secs); 05 Sep 2016 20:33:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.73 as permitted sender) X-Originating-IP: [86.21.161.213] X-Spam: 0 X-Authority: v=2.1 cv=XdR0t9N5 c=1 sm=1 tr=0 a=oo3MgO7t/4XyXFuSzI3dDQ==:117 a=oo3MgO7t/4XyXFuSzI3dDQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=pGLkceISAAAA:8 a=1h9LBggePTMfpSNjaYwA:9 a=q1Jc7bmB78Tn3Sm7:21 a=tAEIEAcKOKjrfuCb:21 a=CjuIK1q_8ugA:10 a=z9dJwno5l634igLiVhy-:22 a=6kGIvZw6iX1k4Y-7sg4_:22 Date: Mon, 5 Sep 2016 21:27:24 +0100 From: Peter Stephenson To: Zsh hackers list Cc: Patrick Hilhorst Subject: Re: Crash on tab completion Message-ID: <20160905212724.1d05ed9e@ntlworld.com> In-Reply-To: References: X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 5 Sep 2016 10:18:57 -0700 Bart Schaefer wrote: > On Mon, Sep 5, 2016 at 3:42 AM, Patrick Hilhorst > 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 ! */