From: Zoltan Hidvegi <hzoli@ny.frontiercomm.net>
To: zsh-workers@math.gatech.edu (Zsh hacking and development)
Subject: Re: Core dump in 3.0.3-test5
Date: Mon, 12 May 1997 04:02:20 -0400 (EDT) [thread overview]
Message-ID: <199705120802.EAA02116@hzoli.home> (raw)
In-Reply-To: <970511112119.ZM20070@candle.brasslantern.com> from Bart Schaefer at "May 11, 97 11:21:19 am"
> 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);
}
/**/
next prev parent reply other threads:[~1997-05-12 8:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-05-11 18:21 Bart Schaefer
1997-05-12 8:02 ` Zoltan Hidvegi [this message]
1997-05-12 8:58 ` Peter Stephenson
1997-05-12 9:25 ` Oops (was Re: Core dump in 3.0.3-test5) Peter Stephenson
1997-05-12 17:41 ` Core dump in 3.0.3-test5 Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199705120802.EAA02116@hzoli.home \
--to=hzoli@ny.frontiercomm.net \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).