Skip to content

Commit 38a25e9

Browse files
authored
gh-120244: Fix re.sub() reference leak (GH-120245)
1 parent 55402d3 commit 38a25e9

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed
Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)