From 03783a7d1bfb96adda5bd60a188ac6411c133ad2 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 10 Dec 2017 19:56:36 +0100 Subject: [PATCH] tweaks: trim another placing of a terminating nul byte Make both preceding character moves include the terminating byte. --- src/text.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/text.c b/src/text.c index ccdd507e..dc420045 100644 --- a/src/text.c +++ b/src/text.c @@ -573,11 +573,10 @@ bool comment_line(undo_type action, filestruct *line, const char *comment_seq) /* Make room for the comment sequence(s), move the text right and * copy them in. */ line->data = charealloc(line->data, line_len + pre_len + post_len + 1); - charmove(line->data + pre_len, line->data, line_len); + charmove(line->data + pre_len, line->data, line_len + 1); charmove(line->data, comment_seq, pre_len); - if (post_len) - charmove(line->data + pre_len + line_len, post_seq, post_len); - line->data[pre_len + line_len + post_len] = '\0'; + if (post_len > 0) + charmove(line->data + pre_len + line_len, post_seq, post_len + 1); openfile->totsize += pre_len + post_len;