From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14782 invoked from network); 31 Oct 2008 11:10:46 -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.6 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; 31 Oct 2008 11:10:46 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 53396 invoked from network); 31 Oct 2008 11:10:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Oct 2008 11:10:40 -0000 Received: (qmail 1788 invoked by alias); 31 Oct 2008 11:10:35 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25983 Received: (qmail 1778 invoked from network); 31 Oct 2008 11:10:34 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 31 Oct 2008 11:10:34 -0000 Received: from n32.bullet.mail.ukl.yahoo.com (n32.bullet.mail.ukl.yahoo.com [87.248.110.149]) by bifrost.dotsrc.org (Postfix) with SMTP id 1A16C80524C0 for ; Fri, 31 Oct 2008 12:10:27 +0100 (CET) Received: from [217.146.182.177] by n32.bullet.mail.ukl.yahoo.com with NNFMP; 31 Oct 2008 11:10:27 -0000 Received: from [87.248.111.150] by t3.bullet.ukl.yahoo.com with NNFMP; 31 Oct 2008 11:10:27 -0000 Received: from [127.0.0.1] by omp207.mail.ukl.yahoo.com with NNFMP; 31 Oct 2008 11:10:27 -0000 X-Yahoo-Newman-Id: 405525.34251.bm@omp207.mail.ukl.yahoo.com Received: (qmail 70437 invoked from network); 31 Oct 2008 11:10:27 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:Received:From:To:Subject:Date:Message-ID; b=dlkMLxyCdU73ve3CAGwVJ8g8PH1CokfDrbv+9l+bg6gbASSNo70+CXKEl3h4WkAX6cIrpxai5kzFQRF7kcST5cLiDVsnHFqPQASMAw/OcfHxFsIiBYlbULB3lTc3Nqs/lU+vf+7VWd49B8Vt83ENJ4LYTfEP0CjKT02Oc/5cRkE= ; Received: from unknown (HELO thecus) (okiddle@89.60.243.114 with plain) by smtp135.mail.ukl.yahoo.com with SMTP; 31 Oct 2008 11:10:27 -0000 X-YMail-OSG: irqmHX8VM1kXOrhs6avG4L_fR2aH.ss5AgPRYZR63zx.rzc5ciCL9vGOBpO7YdnsZqJJXO6ZPfXvFgjAMRCMPFLAcP3g5QzOsRcmHXVpV4OcdCZT5qexBQLTZR__yEYG_22YFJ3HGPmzMnEfFnOc1DkZg3Gb2ZX64cyxMAo- X-Yahoo-Newman-Property: ymail-3 Received: from localhost ([127.0.0.1] helo=thecus) by thecus with esmtp (Exim 4.63) (envelope-from ) id 1KvrtZ-0005zr-Fw for zsh-workers@sunsite.dk; Fri, 31 Oct 2008 12:10:25 +0100 From: Oliver Kiddle To: Zsh workers Subject: PATCH: bug with hash builtin Date: Fri, 31 Oct 2008 12:10:25 +0100 Message-ID: <23054.1225451425@thecus> X-Virus-Scanned: ClamAV 0.92.1/8547/Fri Oct 31 10:27:15 2008 on bifrost X-Virus-Status: Clean This was found by coverity: hash = causes a seg fault. A patch is below. I'm not sure about the error message because it isn't really an assignment but I can't think of anything better. Does anyone think it would be better to avoid the use of the continue statement here at the cost of having to further indent quite a few lines. Oliver Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.215 diff -u -r1.215 builtin.c --- Src/builtin.c 30 Oct 2008 19:52:44 -0000 1.215 +++ Src/builtin.c 31 Oct 2008 11:00:22 -0000 @@ -3262,7 +3262,7 @@ } queue_signals(); - while (*argv) { + for (;*argv;++argv) { void *hn; if (OPT_ISSET(ops,'m')) { /* with the -m option, treat the argument as a glob pattern */ @@ -3275,7 +3275,12 @@ zwarnnam(name, "bad pattern : %s", *argv); returnval = 1; } - } else if ((asg = getasg(*argv)) && asg->value) { + continue; + } + if (!(asg = getasg(*argv))) { + zwarnnam(name, "bad assignment"); + returnval = 1; + } else if (asg->value) { if(isset(RESTRICTED)) { zwarnnam(name, "restricted: %s", asg->value); returnval = 1; @@ -3323,7 +3328,6 @@ ht->printnode(hn, 0); } else if(OPT_ISSET(ops,'v')) ht->printnode(hn, 0); - argv++; } unqueue_signals(); return returnval;