From 49ca7e5aa8033798d6e678b451fc465c143f3491 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 5 Mar 2021 11:16:18 +0100 Subject: [PATCH] memory: do not allocate space for multidata when it's already allocated Allocating it again would leak the existing space. This fixes https://savannah.gnu.org/bugs/?60172. Reported-by: Mike Frysinger Bug existed since version 5.6, commit 1fdd23d3. --- src/color.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/color.c b/src/color.c index a5718269..e0c14a3a 100644 --- a/src/color.c +++ b/src/color.c @@ -305,7 +305,8 @@ void precalc_multicolorinfo(void) /* For each line, allocate cache space for the multiline-regex info. */ for (line = openfile->filetop; line != NULL; line = line->next) - line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short)); + if (!line->multidata) + line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short)); for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) { /* If this is not a multi-line regex, skip it. */