Bug#217092: libc6-dev: leaks memory in regcomp (/usr/include/regex.h)
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.
#include <sys/types.h>
#include <regex.h>
#include <iostream>
#include <string>
void cleanup(int toexit);
regex_t *reg;
bool check_input(std::string in)
{
if(reg == 0)
{
reg = new regex_t;
}
if(int err = regcomp(reg, "^[0-9]+:[A-Za-z,]+:.*$", 0))
cleanup(err);
regmatch_t ptype;
return regexec(reg, in.c_str(), 0, &ptype, 0) != 0;
}
void cleanup(int toexit)
{
if(reg != 0)
{
regfree(reg);
}
exit(toexit);
}
int main(int argc, char *argv[])
{
std::string in = "3520872:all:message";
check_input(in.c_str());
check_input(in.c_str());
cleanup(0);
}
and some of the output from valgrind
==28354== LEAK SUMMARY:
==28354== definitely lost: 348 bytes in 2 blocks.
==28354== possibly lost: 1280 bytes in 1 blocks.
==28354== still reachable: 5588 bytes in 90 blocks.
==28354== suppressed: 0 bytes in 0 blocks.
==28354== Reachable blocks (those to which a pointer was found) are not shown.
==28354== To see them, rerun with: --show-reachable=yes
==28354==
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux paranor 2.4.21-4-k7 #1 Sun Aug 3 02:34:06 EST 2003 i686
Locale: LANG=sv_SE, LC_CTYPE=sv_SE
Versions of packages libc6-dev depends on:
ii libc6 2.3.2-8 GNU C Library: Shared libraries an
-- no debconf information
Reply to: