From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15145 invoked from network); 8 Jan 2009 13:08:34 -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; 8 Jan 2009 13:08:34 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 64165 invoked from network); 8 Jan 2009 13:08:29 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Jan 2009 13:08:29 -0000 Received: (qmail 1911 invoked by alias); 8 Jan 2009 13:08:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26260 Received: (qmail 1899 invoked from network); 8 Jan 2009 13:08:24 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 8 Jan 2009 13:08:24 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id CA9EA806EE5A for ; Thu, 8 Jan 2009 14:08:21 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly14g.srv.mailcontrol.com (MailControl) with ESMTP id n08D70AQ003690 for ; Thu, 8 Jan 2009 13:08:18 GMT Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Jan 2009 13:04:58 +0000 Date: Thu, 8 Jan 2009 13:04:52 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: zsh crash on assignment to $options Message-ID: <20090108130452.621013cb@news01> In-Reply-To: <200901081439.34695.arvidjaar@newmail.ru> References: <200901081439.34695.arvidjaar@newmail.ru> 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: 08 Jan 2009 13:04:58.0345 (UTC) FILETIME=[B5589D90:01C97191] X-Scanned-By: MailControl A_08_51_00 (www.mailcontrol.com) on 10.71.0.124 X-Virus-Scanned: ClamAV 0.92.1/8843/Thu Jan 8 07:01:58 2009 on bifrost X-Virus-Status: Clean On Thu, 8 Jan 2009 14:39:32 +0300 Andrey Borzenkov wrote: > I got this on after > > typeset -A __opts > __opts=${(kv)options} > echo ${options[shwordsplit]} > emulate -R sh > echo ${options[shwordsplit]} > options=$__opts The following should be a safe fix, but there may be similar problems it doesn't pick up. I'm happy to receive reports from pedantic tests of code that's never going to work (but shouldn't crash either). The stuff to do with "foundparam" isn't particularly elegant (or documented). Index: Src/params.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/params.c,v retrieving revision 1.150 diff -u -r1.150 params.c --- Src/params.c 23 Oct 2008 00:48:59 -0000 1.150 +++ Src/params.c 8 Jan 2009 12:59:36 -0000 @@ -498,7 +498,7 @@ static Param foundparam; /**/ -void +static void scanparamvals(HashNode hn, int flags) { struct value v; @@ -538,6 +538,7 @@ --numparamvals; /* Value didn't match, discard key */ } else ++numparamvals; + foundparam = NULL; } /**/ @@ -2270,7 +2271,15 @@ break; case PM_HASHED: { - foundparam->gsu.s->setfn(foundparam, val); + if (foundparam == NULL) + { + zerr("%s: attempt to set associative array to scalar", + v->pm->node.nam); + zsfree(val); + return; + } + else + foundparam->gsu.s->setfn(foundparam, val); } break; } -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070