Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[patch] fix a crash in ${:offset:length} substitution



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@xxxxxxxxx>
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



Messages sorted by: Reverse Date, Date, Thread, Author