]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-120244: Fix re.sub() reference leak (GH-120245) (GH-120265)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 8 Jun 2024 11:10:44 +0000 (13:10 +0200)
committerGitHub <noreply@github.com>
Sat, 8 Jun 2024 11:10:44 +0000 (14:10 +0300)
(cherry picked from commit 38a25e9560cf0ff0b80d9e90bce793ff24c6e027)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst [new file with mode: 0644]
Modules/_sre/sre.c

diff --git a/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst b/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst
new file mode 100644 (file)
index 0000000..d21532f
--- /dev/null
@@ -0,0 +1 @@
+Fix memory leak in :func:`re.sub()` when the replacement string contains backreferences.
index 0547390454a30e3cfafd3c8f6e0f7fd813de4d55..8ef35d0658c703e77d2ebd79c2a4aff6039c990b 100644 (file)
@@ -1572,6 +1572,7 @@ _sre_template_impl(PyObject *module, PyObject *pattern, PyObject *template)
         }
         self->items[i].literal = Py_XNewRef(literal);
     }
+    PyObject_GC_Track(self);
     return (PyObject*) self;
 
 bad_template: