zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: [patch] fix a crash in ${:offset:length} substitution
Date: Tue, 18 Jan 2011 10:37:12 +0100	[thread overview]
Message-ID: <AANLkTikOduomu+RT0cEdtkMQ-G=RSW20Li=3OoXcq6Jo@mail.gmail.com> (raw)

Christian Ruppert reported on IRC that ${foo:0:} crashes, ie nothing
after the second colon, here's a fix. With this, it now produces the
diagnostic
zsh: unrecognized modifier


http://mika.l3ib.org/patches/zsh-0:.patch


commit 70bc02156059277bf98265218d11ffd0c80eea48
Author: Mikael Magnusson <mikachu@gmail.com>
Date:   Tue Jan 18 10:34:50 2011 +0100

    Fix crash with ${:0:}

diff --git a/Src/subst.c b/Src/subst.c
index a153f88..377aba8 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2814,12 +2814,14 @@ paramsubst(LinkList l, LinkNode n, char **str,
int qt, int ssub)
 			zerr("invalid length: %s", check_offset);
 			return NULL;
 		    }
-		    length = mathevali(check_offset);
-		    if (errflag)
-			return NULL;
-		    if (length < (zlong)0) {
-			zerr("invalid length: %s", check_offset);
-			return NULL;
+                    if (check_offset) {
+			length = mathevali(check_offset);
+			if (errflag)
+			    return NULL;
+			if (length < (zlong)0) {
+			    zerr("invalid length: %s", check_offset);
+			    return NULL;
+			}
 		    }
 		}
 		if (horrible_offset_hack) {


-- 
Mikael Magnusson


                 reply	other threads:[~2011-01-18  9:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='AANLkTikOduomu+RT0cEdtkMQ-G=RSW20Li=3OoXcq6Jo@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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).