Skip to content

Commit 11fe96b

Browse files
committed
gh-159739: Initialize template iterator references before allocating
Backport to 3.15 and 3.14.
1 parent 597ae8f commit 11fe96b

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)