From f6357a73f0df80c112f99265b9edb032dbf3c34d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 5 Mar 2021 18:43:43 +0100 Subject: [PATCH] memory: fix an off-by-one error to free also the last line in a group The number of lines in a group is the difference in line numbers between the last line and the first line *plus one*. This fixes https://savannah.gnu.org/bugs/?60104. Bug existed since version 2.9.0, since indenting and unindenting became undoable, and commit f722c532 formed a part of that. --- src/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/text.c b/src/text.c index f1854c2b..0d3c2480 100644 --- a/src/text.c +++ b/src/text.c @@ -951,7 +951,7 @@ void discard_until(const undostruct *thisitem) while (group != NULL) { groupstruct *next = group->next; free_chararray(group->indentations, - group->bottom_line - group->top_line); + group->bottom_line - group->top_line + 1); free(group); group = next; }