Skip to content

Commit aa005aa

Browse files
committed
gh-151815: Fix segfault in template_iter on allocation failure
1 parent 8270ae5 commit aa005aa

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+
Fix segfault in t-string iterator deallocation when :c:func:`PyObject_GetIter`
2+
fails during construction, caused by ``Py_CLEAR`` on uninitialized pointers.

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)