Skip to content

Commit c7c5de4

Browse files
miss-islingtonjelle-openaiJelleZijlstra
authored
[3.14] gh-159739: Initialize template iterator references before allocating (GH-159773) (#159901)
(cherry picked from commit d51e6e5) Co-authored-by: Jelle Zijlstra <jelle@openai.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 7354d53 commit c7c5de4

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Avoid a crash if allocation fails while creating a
2+
:class:`string.templatelib.Template` iterator.

‎Objects/templateobject.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ template_iter(PyObject *op)
226226
if (iter == NULL) {
227227
return NULL;
228228
}
229+
iter->stringsiter = NULL;
230+
iter->interpolationsiter = NULL;
229231

230232
PyObject *stringsiter = PyObject_GetIter(self->strings);
231233
if (stringsiter == NULL) {

0 commit comments

Comments
 (0)