about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/prompt.c2
-rw-r--r--Test/D01prompt.ztst4
3 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 00e335f6c..82d4a7086 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-09  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 41078: Src/prompt.c, Test/D01prompt.ztst: Empty psvar could
+	cause bad reference in prompt expansion.
+
 2017-05-08  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 41059: Completion/compinit: use 2>&- to avoid error in
diff --git a/Src/prompt.c b/Src/prompt.c
index 29e006e0e..c478e69fb 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -399,7 +399,7 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
 			test = 1;
 		    break;
 		case 'V':
-		    if (arrlen_ge(psvar, arg)) {
+		    if (psvar && *psvar && arrlen_ge(psvar, arg)) {
 			if (*psvar[(arg ? arg : 1) - 1])
 			    test = 1;
 		    }
diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index 08187287d..11f18dc71 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -209,3 +209,7 @@
  print -P -f '%%Sfoo%%s\n' bar
 0:print -P -f
 >%Sfoo%s
+
+  print ${(%U)Y-%(v}
+0:Regression test for test on empty psvar
+>