Subject: bug#17341: closed (Re: bug#17341: memory leak in dfa.c)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 25 Apr 2014 06:31:04 +0000

Your bug report

#17341: memory leak in dfa.c

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
17341: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17341
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#17341: memory leak in dfa.c
From: Paul Eggert <[email-masked]>
To: Aharon Robbins <[email-masked]>, [email-masked]
Date: Thu, 24 Apr 2014 23:30:36 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks, I merged that into the master version.

Subject: memory leak in dfa.c
From: Aharon Robbins <[email-masked]>
To: [email-masked]
Date: Thu, 24 Apr 2014 22:19:53 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi.

Thanks to valgrind, I tracked down this memory leak in dfa.c. dfasuperset()
when it does dfafree(sup) doesn't free(sup).  Here's the fix.

Thanks,

Arnold
-----------------------
diff --git a/src/dfa.c b/src/dfa.c
index 8fc3d6f..9106814 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3533,7 +3533,10 @@ dfasuperset (struct dfa *d)
   sup->tindex = j;
 
   if ((d->mb_cur_max == 1 && !have_achar) || !have_nchar)
-    dfafree (sup);
+    {
+      dfafree (sup);
+      free (sup);
+    }
   else
     d->superset = sup;
 }