src/output/tex.c (post_process_tokens): Fix memory leak
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 1 May 2021 06:27:46 +0000 (08:27 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 1 May 2021 06:27:46 +0000 (08:27 +0200)
src/output/tex.c

index 1a4f22fe09a3412e6949300a32ee24fc5c83dab7..7a09c5eae60df1e7d3c6605d6cf430e2a2044674 100644 (file)
@@ -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;
             }
         }