On Wed, Oct 22, 2003 at 07:07:06PM +0200, Alexander Kjall wrote:
> Package: libc6-dev
> Version: 2.3.2-8
> Severity: normal
> 
> A memoryleak in regcomp, a example program is included below plus some
> output from valgrind.
> 
> It might be that i use it wrongly but I don't think so.

You're not calling regfree() between the first and second calls to
regcomp(). Here's a patch:

--- regcompleak.cpp.orig        2003-10-22 19:01:32.000000000 +0100
+++ regcompleak.cpp     2003-10-22 19:03:46.000000000 +0100
@@ -14,6 +14,10 @@
   {
     reg = new regex_t;
   }
+  else
+  {
+    regfree(reg);
+  }

   if(int err = regcomp(reg, "^[0-9]+:[A-Za-z,]+:.*$", 0))
   cleanup(err);

Cheers,

-- 
Colin Watson                                  [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to