summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2016-11-23 11:52:12 +0100
committerOliver Kiddle <opk@zsh.org>2016-11-23 11:52:12 +0100
commitee1222454e0fd58b70878ed6864146e00a835fd8 (patch)
tree781a3e35db69f6e28d2d87dc55097660348bb945
parent85ba68581377c4c77396c016a2bd9da0c107c50e (diff)
downloadzsh-ee1222454e0fd58b70878ed6864146e00a835fd8.tar.gz
zsh-ee1222454e0fd58b70878ed6864146e00a835fd8.tar.xz
zsh-ee1222454e0fd58b70878ed6864146e00a835fd8.zip
unposted: fix printf -v to an array without format string reuse
-rw-r--r--ChangeLog7
-rw-r--r--Src/builtin.c2
-rw-r--r--Test/B03print.ztst6
3 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a70ead69f..641992bd1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2016-11-21  Oliver Kiddle  <okiddle@yahoo.co.uk>
+2016-11-23  Oliver Kiddle  <opk@zsh.org>
+
+	* unposted: Src/builtin.c, Test/B03print.ztst: fix printf -v
+	to an array without format string reuse
+
+2016-11-21  Oliver Kiddle  <opk@zsh.org>
 
 	* 39993: Test/Y01completion.ztst: Tests for 39981.
 
diff --git a/Src/builtin.c b/Src/builtin.c
index d3c628592..ab159ad09 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5034,7 +5034,7 @@ bin_print(char *name, char **args, Options ops, int func)
 	    if (buf)
 		free(buf);
 	} else {
-	    if (visarr) {
+	    if (visarr && splits) {
 		char **arrayval = zshcalloc((cursplit - splits + 2) * sizeof(char *));
 		for (;cursplit >= splits; cursplit--) {
 		    int start = cursplit == splits ? 0 : cursplit[-1];
diff --git a/Test/B03print.ztst b/Test/B03print.ztst
index 6ee2a09c6..3f9a4046d 100644
--- a/Test/B03print.ztst
+++ b/Test/B03print.ztst
@@ -316,3 +316,9 @@
  typeset -p foo
 0:printf into an array variable
 >typeset -a foo=( '1  one' '2  two' '3 three' )
+
+ typeset -a foo
+ print -f '%s' -v foo string
+ typeset -p foo
+0:printf to an array variable without format string reuse
+>typeset foo=string