commit | bf775542b0798afcde4f338aef73553636a9069b | [log] [tgz] |
---|---|---|
author | Benjamin Peterson <benjamin@python.org> | Sat Oct 16 19:20:12 2010 +0000 |
committer | Benjamin Peterson <benjamin@python.org> | Sat Oct 16 19:20:12 2010 +0000 |
tree | e2a3dff42add90c424c25c67ef405a1bd7a0ccd6 | |
parent | f76942d6bf432d6881dc47070002d226e1e15ce9 [diff] [blame] |
iterators passed to writelines() can close their files; don't segfault #10125
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 @@ } 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;