diff --git a/src/prompt.c b/src/prompt.c
index 597895ff82e510ea31b75eb7de1882f9e7cebe1e..34e7b4c02420288b99b1622f683e482b2a558f33 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -518,10 +518,13 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
 	if (kbinput == KEY_WINCH) {
 	    refresh_func();
 	    *actual = KEY_WINCH;
+#ifndef DISABLE_HISTORIES
 	    free(magichistory);
+#endif
 	    return NULL;
 	}
-#endif
+#endif /* !NANO_TINY */
+
 	func = func_from_key(&kbinput);
 
 	if (func == do_cancel || func == do_enter)