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

(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:28 +02:00 committed by GitHub
parent 863a0bd515
commit 9b704ceeca
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: