diff --git a/src/nano.c b/src/nano.c
index 594929c0f744c97a0421a09919c29380be72c129..0e30458791f1e782195ca8146e3c6c78c7a2b717 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2373,15 +2373,14 @@ const char *do_alt_speller(char *tempfile_name)
 	char *invoke_error = _("Could not invoke \"%s\"");
 	int msglen = strlen(invoke_error) + strlen(alt_speller) + 2;
 
-	altspell_error = charalloc(msglen);
-	snprintf(altspell_error, msglen, invoke_error, alt_speller);
-
 #ifndef NANO_SMALL
 	/* Turn the mark back on if it was on before. */
 	if (old_mark_set)
 	    SET(MARK_ISSET);
 #endif
 
+	altspell_error = charalloc(msglen);
+	snprintf(altspell_error, msglen, invoke_error, alt_speller);
 	return altspell_error;
     }