From 4f156aa6db3e9acba4ee9ee86ce82554c40cda49 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 27 Aug 2016 10:48:20 +0200
Subject: [PATCH] prompt: set up the prepared answer before allowing to change
 it

This fixes https://savannah.gnu.org/bugs/?48916.
---
 src/prompt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/prompt.c b/src/prompt.c
index 42db99ca..8a77b296 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -512,7 +512,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
 #ifndef DISABLE_TABCOMP
 	bool allow_files, bool *listed,
 #endif
-	const char *curranswer,
 #ifndef DISABLE_HISTORIES
 	filestruct **history_list,
 #endif
@@ -540,8 +539,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
 #endif
 #endif /* !DISABLE_HISTORIES */
 
-    answer = mallocstrcpy(answer, curranswer);
-
     if (statusbar_x > strlen(answer)) {
 	statusbar_x = strlen(answer);
 	statusbar_pww = statusbar_xplustabs();
@@ -721,6 +718,8 @@ int do_prompt(bool allow_tabs,
 
     bottombars(menu);
 
+    answer = mallocstrcpy(answer, curranswer);
+
     while (retval == KEY_WINCH) {
 	prompt = charalloc((COLS * mb_cur_max()) + 1);
 	va_start(ap, msg);
@@ -733,7 +732,6 @@ int do_prompt(bool allow_tabs,
 #ifndef DISABLE_TABCOMP
 			allow_files, &listed,
 #endif
-			curranswer,
 #ifndef DISABLE_HISTORIES
 			history_list,
 #endif
-- 
GitLab