public inbox for glibc-bugs-regex@sourceware.org help / color / mirror / Atom feed
From: "root at liwave dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs-regex@sources.redhat.com Subject: [Bug regex/1357] New: memory leak in re_compile_pattern() Date: Mon, 19 Sep 2005 21:24:00 -0000 [thread overview] Message-ID: <20050919212445.1357.root@liwave.com> (raw) Calling re_compile_pattern results in a memory leak proportional to the size of the Pattern String. See Example code below: #include <regex.h> #include <stdio.h> int main() { struct re_pattern_buffer *patBuf; const char *ErrStr; char PatStr[128]; unsigned int i; patBuf = (struct re_pattern_buffer *) malloc(sizeof(struct re_pattern_buffer)); if (!patBuf) exit(0); memset(patBuf, 0, sizeof(struct re_pattern_buffer)); patBuf->translate = 0; patBuf->fastmap = 0; patBuf->buffer = (char *) malloc(2048); //Optional patBuf->allocated = 2048; patBuf->regs_allocated = REGS_UNALLOCATED; /Optional patBuf->used = 0; re_set_syntax (RE_SYNTAX_POSIX_EGREP); //Optional for (i = 0; i < 10000; i++) { sprintf(PatStr, "TEST.?STRING%d", i); //This can be anything memset(patBuf->buffer, 0, 2048); ErrStr = re_compile_pattern(PatStr, strlen(PatStr), patBuf); if (ErrStr) printf("ErrStr = %s\n",ErrStr); } //endof for (i = 0; i < 10000; i++) if (patBuf->buffer) free(patBuf->buffer); if (patBuf) free(patBuf); exit(1); } //endof main() Leak was introduced after glibc-2.2.2. This code works fine on a linux 2.4 system running with glibc-2.2.2, leak occures in glibc 2.3.5 and 2.3.1 glibc 2.3.5 was compiled with: CFLAGS="-O3 -march=i686 -mcpu=i686 -funroll-loops -fomit-frame-pointer - fexpensive-optimizations -pipe" -- Summary: memory leak in re_compile_pattern() Product: glibc Version: 2.3.5 Status: NEW Severity: normal Priority: P2 Component: regex AssignedTo: gotom at debian dot or dot jp ReportedBy: root at liwave dot com CC: glibc-bugs-regex at sources dot redhat dot com,glibc- bugs at sources dot redhat dot com GCC host triplet: Linux gentoo 2.6.7-hardened-r18 #2 SMP Sun Jan 16 18:37:38 EST 2 http://sourceware.org/bugzilla/show_bug.cgi?id=1357 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
next reply other threads:[~2005-09-19 21:24 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-09-19 21:24 root at liwave dot com [this message] 2005-10-14 5:49 ` [Bug regex/1357] " drepper at redhat dot com 2005-12-30 20:52 ` drepper at redhat dot com 2006-05-02 21:56 ` drepper at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20050919212445.1357.root@liwave.com \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs-regex@sources.redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).