From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16678 invoked from network); 12 May 1997 08:44:00 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 May 1997 08:44:00 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id EAA06530; Mon, 12 May 1997 04:27:52 -0400 (EDT) Resent-Date: Mon, 12 May 1997 04:27:52 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199705120802.EAA02116@hzoli.home> Subject: Re: Core dump in 3.0.3-test5 In-Reply-To: <970511112119.ZM20070@candle.brasslantern.com> from Bart Schaefer at "May 11, 97 11:21:19 am" To: zsh-workers@math.gatech.edu (Zsh hacking and development) Date: Mon, 12 May 1997 04:02:20 -0400 (EDT) X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"_7mNj3.0.zb1.8IjTp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3130 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > zagzig<1> mv zsh-3.0.3-test5 !#:^-tmp > zsh: no such event: 1 > zagzig<2> mv zsh-3.0.3-test5 !#:^-tmp > mv zsh-3.0.3-test5 zsh-3.0.3-test5 tmp > zsh: segmentation fault (core dumped) ./zsh Fix is below. You may not like this fix: % echo foo !:^-bar zsh: no such word in event Some explanation. When !:^-bar is expanded, there is still only `echo foo' stored in the history. ^- selects everything from the first argument except the last one, which means 1-0 range in this case, which is invalid. And the new behaviour is tcsh compatible. Before this patch zsh corrupted memory on all !:a-b substitution when `b' was less than `a'. The real fix is the first hunk, the second hunk is just a cosmetic optimisation change. Zoltan *** Src/hist.c 1997/05/11 06:42:21 3.1.2.4 --- Src/hist.c 1997/05/12 07:48:55 *************** *** 1153,1163 **** char * getargs(Histent elist, int arg1, int arg2) { - char *ret; short *words = elist->words; int pos1, nwords = elist->nwords; ! if (arg1 >= nwords || arg2 >= nwords) { /* remember, argN is indexed from 0, nwords is total no. of words */ inerrflush(); zerr("no such word in event", NULL, 0); --- 1153,1162 ---- char * getargs(Histent elist, int arg1, int arg2) { short *words = elist->words; int pos1, nwords = elist->nwords; ! if (arg2 < arg1 || arg1 >= nwords || arg2 >= nwords) { /* remember, argN is indexed from 0, nwords is total no. of words */ inerrflush(); zerr("no such word in event", NULL, 0); *************** *** 1165,1174 **** } pos1 = words[2*arg1]; ! ret = dupstring(elist->text + pos1); ! ret[words[2*arg2+1] - pos1] = '\0'; ! ! return ret; } /**/ --- 1164,1170 ---- } pos1 = words[2*arg1]; ! return dupstrpfx(elist->text + pos1, words[2*arg2+1] - pos1); } /**/