summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/utils.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0040c2367..488f1ed45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,11 @@
 	* 39947: Test/D04parameter.ztst: Test out-of-rantge multiple
 	array subscripts with and without (@).
 
+2016-11-14  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 39943: Src/utils.c: no need to compute arrlen() in arrdup_max()
+	when max == 0.
+
 2016-11-15  Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
 
 	* 39937: Src/params.c: fix a problem introduced by 39886.
diff --git a/Src/utils.c b/Src/utils.c
index 92d831172..151e9e4eb 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4252,9 +4252,10 @@ mod_export char **
 arrdup_max(char **s, unsigned max)
 {
     char **x, **y, **send;
-    int len;
+    int len = 0;
 
-    len = arrlen(s);
+    if (max)
+	len = arrlen(s);
 
     /* Limit has sense only if not equal to len */
     if (max > len)