summaryrefslogtreecommitdiff
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-10-16 19:20:12 +0000
committerBenjamin Peterson <benjamin@python.org>2010-10-16 19:20:12 +0000
commitd06c8c362ae32f88a5ff6d3a6029e58ddbe5b676 (patch)
tree8767d8419787ddb860ac4ba5b7426b07f0090d94 /Objects/fileobject.c
parent4ae2284784d277391609872abad365283cb61b6c (diff)
downloadcpython-d06c8c362ae32f88a5ff6d3a6029e58ddbe5b676.tar.gz
iterators passed to writelines() can close their files; don't segfault #10125
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index b7de6a10cd..2647b54269 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -1849,6 +1849,11 @@ file_writelines(PyFileObject *f, PyObject *seq)
}
PyList_SetItem(list, j, line);
}
+ /* The iterator might have closed the file on us. */
+ if (f->f_fp == NULL) {
+ err_closed();
+ goto error;
+ }
}
if (j == 0)
break;