mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 16:21:06 +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>
|
2002-11-05 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/sys/sysctl.h: Add ugly hacks to prevent
|
* 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. */
|
/* We have already checked preg->fastmap != NULL. */
|
||||||
if (BE (ret == REG_NOERROR, 1))
|
if (BE (ret == REG_NOERROR, 1))
|
||||||
{
|
|
||||||
/* Compute the fastmap now, since regexec cannot modify the pattern
|
/* Compute the fastmap now, since regexec cannot modify the pattern
|
||||||
buffer. */
|
buffer. This function nevers fails in this implementation. */
|
||||||
if (BE (re_compile_fastmap (preg) == -2, 0))
|
(void) __re_compile_fastmap (preg);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* Some error occurred while computing the fastmap, just forget
|
/* Some error occurred while compiling the expression. */
|
||||||
about it. */
|
|
||||||
re_free (preg->fastmap);
|
re_free (preg->fastmap);
|
||||||
preg->fastmap = NULL;
|
preg->fastmap = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (int) ret;
|
return (int) ret;
|
||||||
}
|
}
|
||||||
@ -564,16 +562,12 @@ regerror (errcode, preg, errbuf, errbuf_size)
|
|||||||
weak_alias (__regerror, regerror)
|
weak_alias (__regerror, regerror)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Free dynamically allocated space used by PREG. */
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
regfree (preg)
|
free_dfa_content (re_dfa_t *dfa)
|
||||||
regex_t *preg;
|
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
|
|
||||||
if (BE (dfa != NULL, 1))
|
|
||||||
{
|
|
||||||
re_free (dfa->subexps);
|
re_free (dfa->subexps);
|
||||||
|
|
||||||
for (i = 0; i < dfa->nodes_len; ++i)
|
for (i = 0; i < dfa->nodes_len; ++i)
|
||||||
@ -627,8 +621,21 @@ regfree (preg)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
re_free (dfa->re_str);
|
re_free (dfa->re_str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
re_free (dfa);
|
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);
|
re_free (preg->fastmap);
|
||||||
}
|
}
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
@ -778,14 +785,18 @@ re_compile_internal (preg, pattern, length, syntax)
|
|||||||
|
|
||||||
/* Then create the initial state of the dfa. */
|
/* Then create the initial state of the dfa. */
|
||||||
err = create_initial_state (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. */
|
/* Release work areas. */
|
||||||
free_workarea_compile (preg);
|
free_workarea_compile (preg);
|
||||||
re_string_destruct (®exp);
|
re_string_destruct (®exp);
|
||||||
|
|
||||||
|
if (BE (err != REG_NOERROR, 0))
|
||||||
|
{
|
||||||
|
re_compile_internal_free_return:
|
||||||
|
free_dfa_content (dfa);
|
||||||
|
preg->buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user