From 1c25ce345afc54a9550b47afd6d57f28aef9e75a Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 1 May 2021 08:27:46 +0200 Subject: [PATCH] src/output/tex.c (post_process_tokens): Fix memory leak --- src/output/tex.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/output/tex.c b/src/output/tex.c index 1a4f22fe09..7a09c5eae6 100644 --- a/src/output/tex.c +++ b/src/output/tex.c @@ -175,7 +175,11 @@ post_process_tokens (FILE *file, struct ll_list *list) if (nt->cat == CAT_SPACE || nt->cat == CAT_EOL) break; if (prev_x && (prev_x->cat == CAT_COMMENT) && (nt->cat != CAT_COMMENT)) - break; + { + ds_destroy (&prev_x->str); + free (prev_x); + break; + } word_len += ds_length (&nt->str); prev_x = nt; } @@ -184,6 +188,11 @@ post_process_tokens (FILE *file, struct ll_list *list) { fputs ("\n", file); line_len = 0; + if (tt) + { + ds_destroy (&tt->str); + free (tt); + } continue; } } -- 2.30.2