This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
memory leak on regular expression (regex.c)
- From: amihud bruchim <amihudb at yahoo dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 1 Apr 2008 21:30:56 -0700 (PDT)
- Subject: memory leak on regular expression (regex.c)
Hello,
I found a memory leak on regcomp function - gcc-4.4.2 (i used Memory validator tool to confirm it) .
On regcomp this line if (re_compile_fastmap (preg) == -2)
is the cause to the memory leak (it calls to re_compile_fastmap function that allocates memory that is not release)
The code of my program to see the memory leak is:
int main() {
for (size_t i=0; i<1000000; ++i) {
std::string text("aaaaa");;
static const int MAX_PARTS = 10;
static const int flags = REG_EXTENDED;
regex_t _compiled;
regmatch_t _sub[MAX_PARTS];
int res = regcomp(&_compiled, "aaaaa", flags);
bool matched = (regexec(&_compiled, text.c_str(), MAX_PARTS, _sub, 0) != REG_NOMATCH);
regfree(&_compiled);
}
return 0;
Is there a bug fix to it?
Thanks,
Amihud
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com