diff options
author | neonene <53406459+neonene@users.noreply.github.com> | 2024-06-08 10:22:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-08 10:22:07 (GMT) |
commit | 38a25e9560cf0ff0b80d9e90bce793ff24c6e027 (patch) | |
tree | 73e21bf568ffcd98ffe1ce4c34ef6c03f327a22c | |
parent | 55402d3232ca400ebafe4fe3bd70f252304ebe07 (diff) | |
download | cpython-38a25e9560cf0ff0b80d9e90bce793ff24c6e027.zip cpython-38a25e9560cf0ff0b80d9e90bce793ff24c6e027.tar.gz cpython-38a25e9560cf0ff0b80d9e90bce793ff24c6e027.tar.bz2 |
gh-120244: Fix re.sub() reference leak (GH-120245)
-rw-r--r-- | Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst | 1 | ||||
-rw-r--r-- | Modules/_sre/sre.c | 1 |
2 files changed, 2 insertions, 0 deletions
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 index 0000000..d21532f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst @@ -0,0 +1 @@ +Fix memory leak in :func:`re.sub()` when the replacement string contains backreferences. diff --git a/Modules/_sre/sre.c b/Modules/_sre/sre.c index c1eff63..e330340 100644 --- a/Modules/_sre/sre.c +++ b/Modules/_sre/sre.c @@ -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: |