From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: PATCH: Re: Seg Fault in paramsubst()
Date: Tue, 28 Aug 2001 10:35:59 +0200 [thread overview]
Message-ID: <15243.22511.888850.924717@gargle.gargle.HOWL> (raw)
In-Reply-To: <20010828062406.54685.qmail@web10405.mail.yahoo.com>
Felix Rosencrantz wrote:
> When using this in my completer I would sometimes get seg faults. Below
> is a stack trace from gdb. I think this stack trace would only occur if there
> were either no matches or just one. Though it might just happen in one of
> those situations.
bufferwords() might return a NULL pointer, so we should check if it did.
Everywhere.
Bye
Sven
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.21
diff -u -r1.21 subst.c
--- Src/subst.c 2001/08/07 10:18:32 1.21
+++ Src/subst.c 2001/08/28 08:32:38
@@ -1833,7 +1833,7 @@
} else
list = bufferwords(NULL, val, NULL);
- if (!firstnode(list))
+ if (!list || !firstnode(list))
val = dupstring("");
else if (!nextnode(firstnode(list)))
val = getdata(firstnode(list));
Index: Src/Modules/parameter.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/parameter.c,v
retrieving revision 1.21
diff -u -r1.21 parameter.c
--- Src/Modules/parameter.c 2001/07/09 16:05:14 1.21
+++ Src/Modules/parameter.c 2001/08/28 08:32:38
@@ -1105,9 +1105,9 @@
int i = addhistnum(curhist, -1, HIST_FOREIGN), iw;
Histent he = gethistent(i, GETHIST_UPWARD);
- ll = bufferwords(NULL, NULL, NULL);
- for (n = firstnode(ll); n; incnode(n))
- pushnode(l, getdata(n));
+ if ((ll = bufferwords(NULL, NULL, NULL)))
+ for (n = firstnode(ll); n; incnode(n))
+ pushnode(l, getdata(n));
while (he) {
for (iw = he->nwords - 1; iw >= 0; iw--) {
Index: Src/Zle/zle_misc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v
retrieving revision 1.4
diff -u -r1.4 zle_misc.c
--- Src/Zle/zle_misc.c 2000/05/10 15:01:19 1.4
+++ Src/Zle/zle_misc.c 2001/08/28 08:32:39
@@ -549,13 +549,13 @@
int i;
char *p = NULL;
- l = bufferwords(NULL, NULL, &i);
+ if ((l = bufferwords(NULL, NULL, &i)))
+ for (n = firstnode(l); n; incnode(n))
+ if (!i--) {
+ p = getdata(n);
+ break;
+ }
- for (n = firstnode(l); n; incnode(n))
- if (!i--) {
- p = getdata(n);
- break;
- }
if (p) {
int len = strlen(p);
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
prev parent reply other threads:[~2001-08-28 8:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-24 6:54 Working with the historywords special parameter Felix Rosencrantz
2001-08-24 8:16 ` Sven Wischnowsky
2001-08-24 17:05 ` Bart Schaefer
2001-08-28 6:19 ` Felix Rosencrantz
2001-08-28 15:16 ` Bart Schaefer
2001-08-28 6:24 ` Seg Fault in paramsubst() Felix Rosencrantz
2001-08-28 8:35 ` Sven Wischnowsky [this message]
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=15243.22511.888850.924717@gargle.gargle.HOWL \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.dk \
/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).