diff --git a/src/prompt.c b/src/prompt.c
index 0b73c40bfcc8b6c62016d30d350d54716192af06..025fd20373ff0f0dcc32907d2d1028903c7b78b0 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -615,7 +615,8 @@ int do_prompt(bool allow_tabs, bool allow_files,
 
 	bottombars(menu);
 
-	answer = mallocstrcpy(answer, curranswer);
+	if (answer != curranswer)
+		answer = mallocstrcpy(answer, curranswer);
 
 #ifndef NANO_TINY
   redo_theprompt: