gh-120244: Fix re.sub() reference leak (GH-120245)

This commit is contained in:
neonene 2024-06-08 19:22:07 +09:00 committed by GitHub
parent 55402d3232
commit 38a25e9560
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View file

@ -0,0 +1 @@
Fix memory leak in :func:`re.sub()` when the replacement string contains backreferences.

View file

@ -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: