diff --git a/src/prompt.c b/src/prompt.c
index 1a89a50a0d26f3939c1e134ca970a1331b6de07c..3519a548c16a74da77dd187e274eb236a68f16d2 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -617,7 +617,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
 
 	bottombars(menu);
 
-	if (answer != curranswer)
+	if (answer != curranswer || answer == NULL)
 		answer = mallocstrcpy(answer, curranswer);
 
 #ifndef NANO_TINY