mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-31 15:01:09 +00:00
Update.
2002-11-06 Ulrich Drepper <drepper@redhat.com> * posix/regcomp.c (regcomp): __re_compile_fastmap can never fail. If re_compile_internal failed free fastmap buffer. (free_dfa_content): Broken out of regfree function. Frees all dfa related data. (regfree): Add free_dfa_content. (re_compile_internal): If any of the called functions fails free all dfa related memory.
This commit is contained in:
parent
d97426b7d7
commit
71ccd3308c
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2002-11-06 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* posix/regcomp.c (regcomp): __re_compile_fastmap can never fail.
|
||||
If re_compile_internal failed free fastmap buffer.
|
||||
(free_dfa_content): Broken out of regfree function. Frees all dfa
|
||||
related data.
|
||||
(regfree): Add free_dfa_content.
|
||||
(re_compile_internal): If any of the called functions fails free
|
||||
all dfa related memory.
|
||||
|
||||
2002-11-05 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/sys/sysctl.h: Add ugly hacks to prevent
|
||||
|
@ -499,17 +499,15 @@ regcomp (preg, pattern, cflags)
|
||||
|
||||
/* We have already checked preg->fastmap != NULL. */
|
||||
if (BE (ret == REG_NOERROR, 1))
|
||||
{
|
||||
/* Compute the fastmap now, since regexec cannot modify the pattern
|
||||
buffer. */
|
||||
if (BE (re_compile_fastmap (preg) == -2, 0))
|
||||
buffer. This function nevers fails in this implementation. */
|
||||
(void) __re_compile_fastmap (preg);
|
||||
else
|
||||
{
|
||||
/* Some error occurred while computing the fastmap, just forget
|
||||
about it. */
|
||||
/* Some error occurred while compiling the expression. */
|
||||
re_free (preg->fastmap);
|
||||
preg->fastmap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (int) ret;
|
||||
}
|
||||
@ -564,16 +562,12 @@ regerror (errcode, preg, errbuf, errbuf_size)
|
||||
weak_alias (__regerror, regerror)
|
||||
#endif
|
||||
|
||||
/* Free dynamically allocated space used by PREG. */
|
||||
|
||||
void
|
||||
regfree (preg)
|
||||
regex_t *preg;
|
||||
static void
|
||||
free_dfa_content (re_dfa_t *dfa)
|
||||
{
|
||||
int i, j;
|
||||
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
|
||||
if (BE (dfa != NULL, 1))
|
||||
{
|
||||
|
||||
re_free (dfa->subexps);
|
||||
|
||||
for (i = 0; i < dfa->nodes_len; ++i)
|
||||
@ -627,8 +621,21 @@ regfree (preg)
|
||||
#ifdef DEBUG
|
||||
re_free (dfa->re_str);
|
||||
#endif
|
||||
|
||||
re_free (dfa);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Free dynamically allocated space used by PREG. */
|
||||
|
||||
void
|
||||
regfree (preg)
|
||||
regex_t *preg;
|
||||
{
|
||||
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
|
||||
if (BE (dfa != NULL, 1))
|
||||
free_dfa_content (dfa);
|
||||
|
||||
re_free (preg->fastmap);
|
||||
}
|
||||
#ifdef _LIBC
|
||||
@ -778,14 +785,18 @@ re_compile_internal (preg, pattern, length, syntax)
|
||||
|
||||
/* Then create the initial state of the dfa. */
|
||||
err = create_initial_state (dfa);
|
||||
if (BE (err != REG_NOERROR, 0))
|
||||
goto re_compile_internal_free_return;
|
||||
|
||||
re_compile_internal_free_return:
|
||||
/* Release work areas. */
|
||||
free_workarea_compile (preg);
|
||||
re_string_destruct (®exp);
|
||||
|
||||
if (BE (err != REG_NOERROR, 0))
|
||||
{
|
||||
re_compile_internal_free_return:
|
||||
free_dfa_content (dfa);
|
||||
preg->buffer = NULL;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user