From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7163 invoked from network); 25 Nov 2008 18:36:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 25 Nov 2008 18:36:53 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 16762 invoked from network); 25 Nov 2008 18:36:48 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 Nov 2008 18:36:48 -0000 Received: (qmail 15735 invoked by alias); 25 Nov 2008 18:36:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26091 Received: (qmail 15726 invoked from network); 25 Nov 2008 18:36:43 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 25 Nov 2008 18:36:43 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id E0CC280525B4 for ; Tue, 25 Nov 2008 19:36:40 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly17g.srv.mailcontrol.com (MailControl) with ESMTP id mAPIaGLZ028949 for ; Tue, 25 Nov 2008 18:36:37 GMT Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Tue, 25 Nov 2008 18:36:28 +0000 Date: Tue, 25 Nov 2008 18:36:28 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: Seg. Fault when calling "cd" with set "chpwd" hook from a widget Message-ID: <20081125183628.5194962b@news01> In-Reply-To: <20081125000535.GC30055@unknown> References: <20081125000535.GC30055@unknown> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 25 Nov 2008 18:36:28.0983 (UTC) FILETIME=[BAEA1C70:01C94F2C] X-Scanned-By: MailControl A_08_51_00 (www.mailcontrol.com) on 10.71.0.127 X-Virus-Scanned: ClamAV 0.92.1/8679/Tue Nov 25 14:08:31 2008 on bifrost X-Virus-Status: Clean On Tue, 25 Nov 2008 01:05:37 +0100 Jonas Kramer wrote: > Hi workers, > > I've experienced a seg. fault in zsh when doing the following: >... > This seems to happen in > hist.c:1138, where hptr points to NULL at that point. I tried to fix it > myself, but I can't find a clean solution as I can't find the source of > the problem. Just checking for hptr being NULL in hend() would just fix > the symptom, not the cause I guess. Actually, I think that's the right fix: I recently moved the *hptr = '\0' up to that point because in some cases chline gets accessed quite early, but I didn't do the checks that are usually done before accessing it. Index: Src/hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hist.c,v retrieving revision 1.85 diff -u -r1.85 hist.c --- Src/hist.c 22 Sep 2008 08:47:01 -0000 1.85 +++ Src/hist.c 25 Nov 2008 18:34:28 -0000 @@ -1130,12 +1130,14 @@ && (hist_ignore_all_dups = isset(HISTIGNOREALLDUPS)) != 0) histremovedups(); - /* - * Added the following in case the test "hptr < chline + 1" - * is more than just paranoia. - */ - DPUTS(hptr < chline, "History end pointer off start of line"); - *hptr = '\0'; + if (hptr) { + /* + * Added the following in case the test "hptr < chline + 1" + * is more than just paranoia. + */ + DPUTS(hptr < chline, "History end pointer off start of line"); + *hptr = '\0'; + } addlinknode(hookargs, "zshaddhistory"); addlinknode(hookargs, chline); callhookfunc("zshaddhistory", hookargs, 1, &hookret); -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070