Skip to content

Commit

Permalink
pythongh-120244: Fix re.sub() reference leak (pythonGH-120245)
Browse files Browse the repository at this point in the history
  • Loading branch information
neonene authored and estyxx committed Jul 17, 2024
1 parent 5a51c0a commit f57e871
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix memory leak in :func:`re.sub()` when the replacement string contains backreferences.
1 change: 1 addition & 0 deletions Modules/_sre/sre.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f57e871

Please sign in to comment.