diff --git a/src/gmnlm.c b/src/gmnlm.c
index 92e866a2a58a222f56993e57849c348ead658ab4..25afbaf0ce2621c4559fd34a035a9f944485aa3d 100644
--- a/src/gmnlm.c
+++ b/src/gmnlm.c
@@ -696,11 +696,19 @@ if (!input) {
requesting = false;
break;
}
+ if (input[0] == '\0' && browser->history->prev) {
+ free(input);
+ browser->history = browser->history->prev;
+ set_url(browser, browser->history->url, NULL);
+ break;
+ }
char *new_url = gemini_input_url(
browser->plain_url, input);
+ free(input);
assert(new_url);
set_url(browser, new_url, NULL);
+ free(new_url);
break;
case GEMINI_STATUS_CLASS_REDIRECT:
if (++nredir >= 5) {