diff options
| author | Benjamin Peterson <benjamin@python.org> | 2010-10-16 19:20:12 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2010-10-16 19:20:12 (GMT) |
| commit | bf775542b0798afcde4f338aef73553636a9069b (patch) | |
| tree | e2a3dff42add90c424c25c67ef405a1bd7a0ccd6 /Objects/fileobject.c | |
| parent | f76942d6bf432d6881dc47070002d226e1e15ce9 (diff) | |
| download | cpython-bf775542b0798afcde4f338aef73553636a9069b.zip cpython-bf775542b0798afcde4f338aef73553636a9069b.tar.gz cpython-bf775542b0798afcde4f338aef73553636a9069b.tar.bz2 | |
iterators passed to writelines() can close their files; don't segfault #10125
Diffstat (limited to 'Objects/fileobject.c')
| -rw-r--r-- | Objects/fileobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index b7de6a1..2647b54 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; |
