Skip to content

Commit 46e69f8

Browse files
[3.12] gh-120244: Fix re.sub() reference leak (GH-120245) (GH-120265)
(cherry picked from commit 38a25e9) Co-authored-by: neonene <[email protected]>
1 parent 88f67df commit 46e69f8

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix memory leak in :func:`re.sub()` when the replacement string contains backreferences.

Modules/_sre/sre.c

+1
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,7 @@ _sre_template_impl(PyObject *module, PyObject *pattern, PyObject *template)
15721572
}
15731573
self->items[i].literal = Py_XNewRef(literal);
15741574
}
1575+
PyObject_GC_Track(self);
15751576
return (PyObject*) self;
15761577

15771578
bad_template:

0 commit comments

Comments
 (0)