https://github.com/python/cpython/commit/c7c5de4af88bc350bed89815f9f4691fed5bc74c commit: c7c5de4af88bc350bed89815f9f4691fed5bc74c branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: JelleZijlstra <[email protected]> date: 2026-10-20T11:13:33-07:00 summary:
[3.14] gh-159739: Initialize template iterator references before allocating (GH-159773) (#159901) (cherry picked from commit d51e6e596b7c9f5510203b06a641df0fb579faba) Co-authored-by: Jelle Zijlstra <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]> files: A Misc/NEWS.d/next/Core_and_Builtins/2026-10-19-20-38-17.gh-issue-159739.fc0ed2.rst M Objects/templateobject.c diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-19-20-38-17.gh-issue-159739.fc0ed2.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-19-20-38-17.gh-issue-159739.fc0ed2.rst new file mode 100644 index 00000000000000..6a549a6ded5e6a --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-19-20-38-17.gh-issue-159739.fc0ed2.rst @@ -0,0 +1,2 @@ +Avoid a crash if allocation fails while creating a +:class:`string.templatelib.Template` iterator. diff --git a/Objects/templateobject.c b/Objects/templateobject.c index 1609e82b444516..994b352d7dcd63 100644 --- a/Objects/templateobject.c +++ b/Objects/templateobject.c @@ -226,6 +226,8 @@ template_iter(PyObject *op) if (iter == NULL) { return NULL; } + iter->stringsiter = NULL; + iter->interpolationsiter = NULL; PyObject *stringsiter = PyObject_GetIter(self->strings); if (stringsiter == NULL) { _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
