[3.12] gh-120244: Fix re.sub() reference leak (GH-120245) (GH-120265)

(cherry picked from commit 38a25e9560)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-06-08 13:10:44 +02:00 committed by GitHub
parent 88f67df22c
commit 46e69f8c25
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

@ -1572,6 +1572,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: