Skip to content

Commit 7f857a5

Browse files
committed
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 5873594. Per report from Sandro Santilli; diagnosis by Greg Stark.
1 parent 63817f8 commit 7f857a5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/backend/regex/regexec.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ pg_regexec(regex_t *re,
259259
/* clean up */
260260
if (v->pmatch != pmatch && v->pmatch != mat)
261261
FREE(v->pmatch);
262+
n = (size_t) v->g->ntree;
262263
for (i = 0; i < n; i++)
263264
{
264265
if (v->subdfas[i] != NULL)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy