From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24081 invoked from network); 10 Mar 2022 12:27:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Mar 2022 12:27:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1646915259; b=aHB8He3Mwn7STpZFVnUCx+n78pK6vTe+Jrb3B3NnUlBXqmNoIGlhKxwVOXI85XXGPC631qFlaH Nsv8IDoVXA8ASvJnZemvHhbH14BcLOo10ADAiTshzT0Ggc5ccPgbN2tPQ7D92JE1rwKvNPnNy/ fN4PyUkj0vYzuJPFQ0v8+emIX9LsMYi3kQdhxJbnfU8dC3KJw18vNOZX2mxDPF7crQNKGndLAN 5pUqkARxMPARRqJng246GZ2M1bLtkBLYLH9JaGpc6LD9a4ApQfGWdF+wTd9Zu95Ctkk7BVaAo9 wv+E7ceEUfGI1Q4VwPwRf5pFdAHJ7uoN/pIcpi+18ewxig==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pj1-f52.google.com) smtp.remote-ip=209.85.216.52; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1646915259; bh=NrKLU6vSI20az4h1EFiEeYAzuXAqKKVTd+2BtcRns2o=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=kUES7/aKBfWnFhDSPGxe+vcUmdHIOSRa0mQDk09PbmJi6BwAxUp8WkZnuRWg+siFk9rO7JyDyc 10qL3j5CvSPfYwJRyxdlJsWsRbuYhBcPZyIIn7EDYCW4CvsJCeH9bgKPiygQZFkb9Dbcscqmjh N9N1cxX72rG+qxdyDss7yJJU7NbPpt+ycVWoVmJ738FE2SelBlRvksqKvkzjjUC29T01EPDYFT GdGH5BKjQoG5OQLpe4mW8tqEhxMsBZ25mJ216WimNaqd8/Gv/d/7xFAKfl6if3PcFacY5E0Z0+ Gw3oWdNvHZ45kaQWhINNxP55Bv0AxDUXMfcxnescUDejkw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:References:In-Reply-To:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=hUXSOvUulI2HplW6hi1aQ+8kRAWLT+I2QZPsOxCyclU=; b=bQ+0v9arEHYkDWSLFKf0xMZV9u GDICs8oWkFGtfsWIUjW2kv92TvjfDnk62ziWZUtzi/DbLFMFjtya+8n96AHkU56zTt3+eq4fWd/e3 /y0TmwQFizPMMIGcMI/VHjsX2pP6Lei5z0hVjkDRJ9F9n8pGolyqwGBvKCQgVFs0JLr//+gawlwu/ GIf4viKT4Z1OiC/5qT0qcuPzU5hbONFKP+3HdrDgnmQcpjvDQ0es8ysgDHloPPtFIFTG/QmHAGM6J M4k04Qd0aFSOLzNvfhets2VeTf9gLTcyv/+oM1nXJqPB60NL6US0z73ri9zuwajITwRBUARpg1+Ao kLvgFelw==; Received: from authenticated user by zero.zsh.org with local id 1nSHtJ-0008b1-Iw; Thu, 10 Mar 2022 12:27:37 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pj1-f52.google.com) smtp.remote-ip=209.85.216.52; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pj1-f52.google.com ([209.85.216.52]:55292) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nSHt2-0008Fu-BV; Thu, 10 Mar 2022 12:27:21 +0000 Received: by mail-pj1-f52.google.com with SMTP id b8so5077449pjb.4 for ; Thu, 10 Mar 2022 04:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hUXSOvUulI2HplW6hi1aQ+8kRAWLT+I2QZPsOxCyclU=; b=V2oetnEQotC8Tla5vLUdaWRP13gqB03HCw6IOOcM529toryd9I/MaEKzLT36QAyaOY nQh9py9t4P08KvX5xzXzSu6bNEWOAz4eZwwaol19YBBAQismM9q8Js/2+1U9XiehEdLb 5dp2qNVZJtJu+2LDW4/NkB3tcUETysV++RwnF+5X6UaM/iHq+kHqqXLpXwnDtXoIQaYE L04lBzAkXK3jqDaRH+pqe8M7trQqxmqvmRqza1tBgIPUX3D6hJ+92ZUBdqjRYj8OURqp MFQUqkP52fCS3G/vjt8dP2PgnTu46vjdm2sI1q8MvshiGx8NqB6WssqtLQeWPR0kiWBz OBjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hUXSOvUulI2HplW6hi1aQ+8kRAWLT+I2QZPsOxCyclU=; b=MhJibDCcHRemp/OVFjI9snVQi0oM/xnJyfZYaFNl31C5R7NtR0yxgzf5yhwomhig+h Sq1g9sal7Vk5hWWBUdZtMOzV0o4Cs4w8c09Cu3r57vVGJeNobactrFJFHOSijMydQhBc DhYr7C3/mEHMnXBboFS/02X6DrG88i/135Orgg161gOnyIVYqZ2oVEVbbIe+uSTW5TLL Za1+teMeGFFPegm1Qh7itdiarSyBTSdUh+E38ZGu4wz3S24QYIDNfVd3l7JYwtjYF1tF UuVw9ipyka3ULRXMbqvlTFsCDd0gnIUMbBLOaem6CaIfSNBpmnApXCwGXQjehvHO7eyw McPA== X-Gm-Message-State: AOAM530xSuiIAzpp/pPimUt8SyK35J61ABUNKkPtm6QrBHbkRhT0BUik 6OMAkkf5jIoETavPYpZpa87cMbGLOv44VQjzmM/zZHyx X-Google-Smtp-Source: ABdhPJwq3KVQcaOjeFPv5sDX0YrnOghDZcGl1RGWvxut2hbBF0FIdKfZVdWWs3bv3mmRAh8xFGjmt0UqkUsj/wqKcBA= X-Received: by 2002:a17:902:700b:b0:148:ee33:70fe with SMTP id y11-20020a170902700b00b00148ee3370femr4920047plk.38.1646915238929; Thu, 10 Mar 2022 04:27:18 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:6a10:466:0:0:0:0 with HTTP; Thu, 10 Mar 2022 04:27:18 -0800 (PST) In-Reply-To: References: <20220308193246.3204-1-mikachu@gmail.com> From: Mikael Magnusson Date: Thu, 10 Mar 2022 13:27:18 +0100 Message-ID: Subject: Re: PATCH: [RFC] crash with weird completer To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49820 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 3/10/22, Bart Schaefer wrote: > On Tue, Mar 8, 2022 at 11:33 AM Mikael Magnusson wrote: >> >> type "foo " and press tab twice, and it should crash. > > Alternate patch below. This differs in that it initializes the > "lastprebr" array, which step is skipped by Mikael's patch. > >> The patch prevents the crash but I have no further arguments that it's >> correct. > > Ditto. > > You can work around this by quoting the braces that should be treated > literally: > compdef _foo foo;_foo() { compadd -Q -- stash@\\{{0,1}\\} } I don't remember the thought process that led to the test case, but in that case you could just drop the -Q too, right? > The patch: Hmm, I guess this is safer in the case that somehow m->brpl is set but a subsequent brpos is NULL. It's probably (definitely) not worth bothering about skipping NULL entries to process other ones (eg, continue instead of break when !brpos) I was staring at the original diff in gmail trying to figure out what I was looking at, and this should be equivalent to your patch but spare the eyes of future generations slightly (this is directed at the original code, not your patch), diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index 8b5955819a..0fed297b56 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -612,9 +612,10 @@ instmatch(Cmatch m, int *scs) int pcs = zlemetacs; l = 0; - for (bp = brbeg, brpos = m->brpl, - bradd = (m->pre ? strlen(m->pre) : 0); - bp; bp = bp->next, brpos++) { + bradd = (m->pre ? strlen(m->pre) : 0); + for (bp = brbeg, brpos = m->brpl; + bp && brpos; + bp = bp->next, brpos++) { zlemetacs = a + *brpos + bradd; pcs = zlemetacs; l = strlen(bp->str); Eg, bradd is not involved with the loop condition at all, so don't set it in the for-initializer, and put each foo;bar;baz; on separate lines. -- Mikael Magnusson