]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-120244: Fix re.sub() reference leak (GH-120245)
authorneonene <53406459+neonene@users.noreply.github.com>
Sat, 8 Jun 2024 10:22:07 +0000 (19:22 +0900)
committerGitHub <noreply@github.com>
Sat, 8 Jun 2024 10:22:07 +0000 (10:22 +0000)
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 c1eff63d921de94cf128feed71689c7bbb1b82e8..e33034086481c23174cbca8dc797cab8cf3f0e64 100644 (file)
@@ -1622,6 +1622,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: