zsh/subst-crash.patch

37 lines
1.1 KiB
Diff

From aa58d139ff3ffa7258a6273bf279d70f9ee31916 Mon Sep 17 00:00:00 2001
From: Peter Stephenson <pws@users.sourceforge.net>
Date: Tue, 18 Jan 2011 10:29:58 +0000
Subject: [PATCH] Mikael: 28637: ${foo:0:} caused crash
---
ChangeLog | 6 +++++-
Src/subst.c | 14 ++++++++------
Test/D04parameter.ztst | 5 +++++
3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/Src/subst.c b/Src/subst.c
index 24d515d..37d63ca 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) {