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 Jun 8, 2024
1 parent 55402d3 commit 38a25e9
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 38a25e9

Please sign in to comment.