diff --git a/src/text.c b/src/text.c
index a70e10a20e372787beb91742c5e01ded4a0d802f..c0629a8f488af89fe64653ed62d68b54870f9320 100644
--- a/src/text.c
+++ b/src/text.c
@@ -501,6 +501,7 @@ void do_redo(void)
 	undidmsg = _("text add");
 	len = strlen(f->data) + strlen(u->strdata) + 1;
         data = charalloc(len);
+	strncpy(data, f->data, u->begin);
 	strcpy(&data[u->begin], u->strdata);
 	strcpy(&data[u->begin + strlen(u->strdata)], &f->data[u->begin]);
 	free(f->data);