groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] Re: memory leaks in grohtml


From: Gaius Mulley
Subject: [Groff] Re: memory leaks in grohtml
Date: Fri, 21 Feb 2003 12:07:21 +0000

Hi Werner,

> I've run valgrind like this:
>
>  valgrind --logfile-fd=3 \
>           --show-reachable=yes \
>           --leak-check=yes \
>           --trace-children=yes \
>    groff -Thtml -pte -ms -ww pic.ms > pic.html 3> pic.html.log
>
> and I get some large memory leaks (the line numbers may be slightly
> off with the current CVS since I tried to fix some of the smaller
> leaks which I was able to trace).  Can you please check the problems?

here are some patches which address a number of the problems
that valgrind detects. Thanks for the report, valgrind highlighted
a number of oversights!

Gaius


--- groff-cvs/src/devices/grohtml/html-table.cc 2002-08-01 13:28:54.000000000 
+0100
+++ groff-html/src/devices/grohtml/html-table.cc        2003-02-21 
11:55:30.000000000 +0000
@@ -235,8 +235,16 @@
 
 html_table::~html_table ()
 {
+  cols *c;
   if (tab_stops != NULL)
     delete tab_stops;
+  
+  c = columns;
+  while (columns != NULL) {
+    columns = columns->next;
+    free(c);
+    c = columns;
+  }
 }
 
 /*
--- groff-cvs/src/devices/grohtml/post-html.cc  2003-02-15 07:24:09.000000000 
+0000
+++ groff-html/src/devices/grohtml/post-html.cc 2003-02-21 12:10:59.000000000 
+0000
@@ -261,6 +261,7 @@
 
   char_block();
   char_block(int length);
+  ~char_block();
 };
 
 char_block::char_block()
@@ -276,6 +277,12 @@
     fatal("out of memory error");
 }
 
+char_block::~char_block()
+{
+  if (buffer != NULL)
+    free(buffer);
+}
+
 class char_buffer {
 public:
   char_buffer();
@@ -448,6 +455,7 @@
                               min_vertical, min_horizontal, max_vertical, 
max_horizontal,
                               FALSE, FALSE, FALSE, FALSE, 0);
   *this = *g;
+  delete g;
 }
 
 /*
@@ -465,6 +473,7 @@
                               min_vertical, min_horizontal, max_vertical, 
max_horizontal,
                               FALSE, FALSE, TRUE, FALSE, 0);
   *this = *g;
+  delete g;
 }
 
 /*
@@ -480,6 +489,7 @@
                               min_vertical, min_horizontal, max_vertical, 
max_horizontal,
                               FALSE, FALSE, FALSE, TRUE, thickness);
   *this = *g;
+  delete g;
 }
 
 /*
@@ -513,6 +523,7 @@
                               min_vertical, min_horizontal, max_vertical, 
max_horizontal,
                               TRUE, TRUE, FALSE, FALSE, 0);
   *this = *g;
+  delete g;
 }
 
 /*
@@ -527,6 +538,7 @@
                               min_vertical, min_horizontal, max_vertical, 
max_horizontal,
                               TRUE, FALSE, FALSE, FALSE, 0);
   *this = *g;
+  delete g;
 }
 
 /*
@@ -747,6 +759,8 @@
 
 void text_glob::remember_table (html_table *t)
 {
+  if (tab != NULL)
+    delete tab;
   tab = t;
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]