Skip to content
Snippets Groups Projects
Commit ea8c7e90 authored by Tom Lane's avatar Tom Lane
Browse files

Fix memory leak during regular expression execution.

For a regex containing backrefs, pg_regexec() might fail to free all the
sub-DFAs that were created during execution, resulting in a permanent
(session lifespan) memory leak.  Problem was introduced by me in commit
58735947.  Per report from Sandro Santilli;
diagnosis by Greg Stark.
parent fb1d92a9
No related branches found
No related tags found
No related merge requests found
...@@ -259,6 +259,7 @@ pg_regexec(regex_t *re, ...@@ -259,6 +259,7 @@ pg_regexec(regex_t *re,
/* clean up */ /* clean up */
if (v->pmatch != pmatch && v->pmatch != mat) if (v->pmatch != pmatch && v->pmatch != mat)
FREE(v->pmatch); FREE(v->pmatch);
n = (size_t) v->g->ntree;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
if (v->subdfas[i] != NULL) if (v->subdfas[i] != NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment