diff --git a/src/text.c b/src/text.c
index af1e02cb0d0e000fae6268b515da4d1362bc9d01..68b64ed37140d48071aee602b1875ca503087826 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1184,6 +1184,7 @@ void discard_until(const undo *thisitem, openfilestruct *thefile, bool keep)
 			free(group);
 			group = next;
 		}
+		free(dropit);
 		dropit = thefile->undotop;
 	}