From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26345 invoked by alias); 26 Jun 2015 23:07:05 -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: 35623 Received: (qmail 425 invoked from network); 26 Jun 2015 23:07:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1435359681; bh=Dw4SCmGQCcqU9JKhySmFedv/ddJnLyn6AJ+bfMqdP6Q=; h=From:To:Subject:Date:From:Subject; b=LZPPFOkfzkaWsFOhDNa+dz3vCBALnrCIqS0r9WqvvwHKet0tuNWUK2KeEx7oKMIbj4TqKmYoWBGMQqlEesBXxwq542ga1GIgBeCuTS52tNYPlT1tsTLQtkSFnO7Qwo+cJW9Zl8h7XGjKIy3nOUSzRt+6WJE+/1ic5hJLMgSvQMYCSGF7GAg/LtEmQG4ElopONvdiwkIW3CSl59uOB7B9e6fDXIokgcxwWRhs71T+r8gr4nf2TmGyukgUpwLUgj1mfz1kmhHgmpPASmjdCUkBs62Z8uZwSpRXvaXn4tigFkiBTUR+wDstxO51RKjBlfXhEzNc9VKxXv1Rke96RgrWgw== X-Yahoo-Newman-Id: 902832.16891.bm@smtp141.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: pGyzSlsVM1kNJw995uymOPYRYMZSRdU4XxX2QL1r4H7wF25 NghwXZIknCvJ0nWwZeuzNiJl2OFPlrBWY8e5CldkmIlYF_fNlZj8GSGV.nTQ tqXt6zV08JS6OSEVQccd2kSF843VdrUDocr9yVTi.VY26bu1zE2iL.N6E9Dp TywQnYFg1um_nL9OgurKjLAgJvc10NebgtTzt_BIfrbf35Iw8qIxOUF0dE_z g7zoHkvEsREs9zvKQPi2dQRgpCCs_F2kXe1Lbk1WGLbF5SbIx3_s9pNDvHWP FSndL52VTGFB37TBIwL.XNThe6lNvwmEjlpmKVSFVV0G6dGsjO763z8clO8q 8.dU_VJzqFD1764YAwBHY46pkxNXf3ea_IjAB81KadJG1Kc3h87L4L0eClTa QZ8lzCPBEPruUMXLkTwDOja_RMpYKCIIm03MfcFXPrsY4qpnaf05A7BT8cO. B_gMDGRSb1MNVH.v5sHlE6nTi71AKTU6EpFQr1EDS_CRuSQ4aYYo5X4xq9IL NljpMmIHJU8jB2HhsbhGmiATiSKrArQ-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: menu-selection null deref if initial selection not in display MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25789.1435359680.1@thecus.kiddle.eu> Date: Sat, 27 Jun 2015 01:01:20 +0200 Message-ID: <25790.1435359680@thecus.kiddle.eu> When menu select starts, if the initially selected match would require a scrolled display, it seg faults. mline is used to identify the line in the display on which the current selection is but it is initialised to 0 and doesn't get set correctly if it should actually start out as something other than 0. Steps to reproduce this are as follows. autoload -U compinit;compinit zstyle ':completion*:default' menu select zmodload zsh/complist _segf() { local m disp m=( {01..$LINES}:description ) zformat -a disp " -- " $m compstate[insert]="menu:-1" compadd -ld disp -a m } compdef _segf segf segf The patch below allows the code to go back to the beginning of the main for loop in domenucomplete. mtab_been_reallocated has been set and so mline will be calculated. You can create a similar situation by reducing the size of the terminal window until the selection is obscured. That only results in a messed up display but would be trickier to fix because the code path in that case goes straight from zrefresh() to complistmatches(). If I resize the window a lot with menu-selectiona active, I can fairly reliably get it to crash after not too long. Oliver diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index aae6504..f37a432 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -2071,6 +2071,7 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) memset(mgtab, 0, i * sizeof(Cmgroup)); mlastcols = mcols = zterm_columns; mlastlines = mlines = listdat.nlines; + mmtabp = 0; } last_cap = (char *) zhalloc(max_caplen + 1); *last_cap = '\0'; @@ -2562,6 +2563,8 @@ domenuselect(Hookdef dummy, Chdata dat) } p = mmtabp; pg = mgtabp; + if (!p) /* selected match not in display, find line */ + continue; minfo.cur = *p; minfo.group = *pg; if (setwish)