diff options
author | Roland McGrath <roland@gnu.org> | 2002-10-24 00:22:27 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2002-10-24 00:22:27 +0000 |
commit | 240e87c2300c25b1cc8a78cccc2293874d89c67e (patch) | |
tree | 9ae48ca9bb0d09bea6c218950c86e000378d1b88 /posix/regcomp.c | |
parent | 3efdabe7624ae0a574d3919cfe9ffcb5bca21692 (diff) | |
download | glibc-240e87c2300c25b1cc8a78cccc2293874d89c67e.tar glibc-240e87c2300c25b1cc8a78cccc2293874d89c67e.tar.gz glibc-240e87c2300c25b1cc8a78cccc2293874d89c67e.tar.bz2 glibc-240e87c2300c25b1cc8a78cccc2293874d89c67e.zip |
* posix/regcomp.c (re_comp): Call __regfree on re_comp_buf.
(free_mem): New function.
* posix/Makefile (tests): Add bug-regex14. Add bug-regex14-mem
if not cross compiling.
(generated): Add bug-regex14-mem and bug-regex14.mtrace.
(bug-regex14-ENV): Set.
(bug-regex14-mem): New target.
* posix/bug-regex14.c: New file.
* elf/Makefile ($(objpfx)librtld.map): Use temporary file for output
target, so we don't touch it when the link fails.
Diffstat (limited to 'posix/regcomp.c')
-rw-r--r-- | posix/regcomp.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/posix/regcomp.c b/posix/regcomp.c index 497d1301df..9bb06aa7bf 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -653,6 +653,7 @@ re_comp (s) const char *s; { reg_errcode_t ret; + char *fastmap; if (!s) { @@ -661,7 +662,17 @@ re_comp (s) return 0; } - if (!re_comp_buf.buffer) + if (re_comp_buf.buffer) + { + fastmap = re_comp_buf.fastmap; + re_comp_buf.fastmap = NULL; + __regfree (&re_comp_buf); + re_comp_buf.buffer = NULL; + re_comp_buf.allocated = 0; + re_comp_buf.fastmap = fastmap; + } + + if (re_comp_buf.fastmap == NULL) { re_comp_buf.fastmap = (char *) malloc (SBC_MAX); if (re_comp_buf.fastmap == NULL) @@ -683,6 +694,16 @@ re_comp (s) /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); } + +#ifdef _LIBC +static void __attribute__ ((unused)) +free_mem (void) +{ + __regfree (&re_comp_buf); +} +text_set_element (__libc_subfreeres, free_mem); +#endif + #endif /* _REGEX_RE_COMP */ /* Internal entry point. |