Skip to content

Commit 9b704ce

Browse files
[3.13] gh-120244: Fix re.sub() reference leak (GH-120245) (GH-120264)
(cherry picked from commit 38a25e9) Co-authored-by: neonene <[email protected]>
1 parent 863a0bd commit 9b704ce

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
@@ -1622,6 +1622,7 @@ _sre_template_impl(PyObject *module, PyObject *pattern, PyObject *template)
16221622
}
16231623
self->items[i].literal = Py_XNewRef(literal);
16241624
}
1625+
PyObject_GC_Track(self);
16251626
return (PyObject*) self;
16261627

16271628
bad_template:

0 commit comments

Comments
 (0)