zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@sunsite.dk
Subject: Re: [Bug] ZSH segmentation fault
Date: Sun, 03 Jun 2007 18:36:10 +0100	[thread overview]
Message-ID: <200706031736.l53HaAJI003047@pws-pc.ntlworld.com> (raw)
In-Reply-To: Message from DervishD <zsh@dervishd.net>  of "Sun, 03 Jun 2007 18:43:56 +0200." <20070603164356.GA21731@DervishD>

DervishD wrote:
>     While I understand that running such scripts is very unusual, I
> think that just segfaulting is not a correct way of dealing with errors.

I didn't claim it was, indeed I think I implied the opposite.

I can easily work around this one, though even this isn't completely
trivial.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.115
diff -u -r1.115 exec.c
--- Src/exec.c	29 May 2007 14:16:03 -0000	1.115
+++ Src/exec.c	3 Jun 2007 17:32:50 -0000
@@ -3111,7 +3111,13 @@
 	    ;
 	for (;;) {
 	    if (bptr == buf + bsiz) {
-		buf = realloc(buf, 2 * bsiz);
+		char *newbuf = realloc(buf, 2 * bsiz);
+		if (!newbuf) {
+		    /* out of memory */
+		    zfree(buf, bsiz);
+		    return NULL;
+		}
+		buf = newbuf;
 		t = buf + bsiz - (bptr - t);
 		bptr = buf + bsiz;
 		bsiz *= 2;
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.38
diff -u -r1.38 lex.c
--- Src/lex.c	23 Jan 2007 16:07:47 -0000	1.38
+++ Src/lex.c	3 Jun 2007 17:32:51 -0000
@@ -356,6 +356,16 @@
 	    ALLOWHIST
 	    cmdpop();
 	    hwend();
+	    if (!name) {
+		zerr("here document too large");
+		while (hdocs) {
+		    next = hdocs->next;
+		    zfree(hdocs, sizeof(struct heredocs));
+		    hdocs = next;
+		}
+		tok = LEXERR;
+		break;
+	    }
 	    setheredoc(hdocs->pc, REDIR_HERESTR, name);
 	    zfree(hdocs, sizeof(struct heredocs));
 	    hdocs = next;

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2007-06-03 17:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <matthieu.kermagoret@epita.fr>
2007-06-03 10:02 ` matthieu kermagoret
2007-06-03 14:30   ` Peter Stephenson
2007-06-03 16:43     ` DervishD
2007-06-03 17:36       ` Peter Stephenson [this message]
2007-06-03 19:16         ` DervishD
2007-06-04  0:55         ` 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=200706031736.l53HaAJI003047@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --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).