leaked regular expression (regfree not called)

This commit is contained in:
Seth Heeren 2010-10-03 02:50:54 +02:00 committed by Curtis Gedak
parent 29e4329182
commit e61b5ff240
1 changed files with 5 additions and 4 deletions

View File

@ -307,11 +307,12 @@ Glib::ustring Utils::regexp_label( const Glib::ustring & text,
int nmatch = 2 ; int nmatch = 2 ;
regmatch_t pmatch[ 2 ] ; regmatch_t pmatch[ 2 ] ;
int rc = regcomp( &preg, regular_sub_expression .c_str(), REG_EXTENDED | REG_ICASE | REG_NEWLINE ) ; int rc = regcomp( &preg, regular_sub_expression .c_str(), REG_EXTENDED | REG_ICASE | REG_NEWLINE ) ;
if ( ( rc == 0 ) //Reg compile OK if(rc == 0)
&& ( regexec( &preg, text .c_str(), nmatch, pmatch, 0 ) == 0 ) //Match found
)
{ {
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 ) ; label = text .substr( pmatch[1].rm_so, pmatch[1].rm_eo - pmatch[1].rm_so ) ;
regfree(&preg);
} }
return label ; return label ;
} }