[gparted] leaked regular expression (regfree not called)



commit e61b5ff2400b9818ba61836db8e8a4d0d3fd8353
Author: Seth Heeren <sgheeren hotmail com>
Date:   Sun Oct 3 02:50:54 2010 +0200

    leaked regular expression (regfree not called)

 src/Utils.cc |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/Utils.cc b/src/Utils.cc
index b42b750..53ac33d 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -307,11 +307,12 @@ Glib::ustring Utils::regexp_label( const Glib::ustring & text,
 	int        nmatch = 2 ;
 	regmatch_t pmatch[  2 ] ;
 	int rc = regcomp( &preg, regular_sub_expression .c_str(), REG_EXTENDED | REG_ICASE | REG_NEWLINE ) ;
-	if (   ( rc == 0 ) //Reg compile OK
-		&& ( regexec( &preg, text .c_str(), nmatch, pmatch, 0 ) == 0 ) //Match found
-	   )
+    if(rc == 0)
 	{
-		label = text .substr( pmatch[1].rm_so, pmatch[1].rm_eo - pmatch[1].rm_so ) ;
+		if (regexec(&preg, text.c_str(), nmatch, pmatch, 0) == 0)
+			label = text .substr( pmatch[1].rm_so, pmatch[1].rm_eo - pmatch[1].rm_so ) ;
+
+		regfree(&preg);
 	}
 	return label ;
 }



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