Commit ed02eb6a authored by Georg Brandl's avatar Georg Brandl

Bug #1177964: make file iterator raise MemoryError on too big files

parent 644b1e7a
...@@ -1797,7 +1797,7 @@ drop_readahead(PyFileObject *f) ...@@ -1797,7 +1797,7 @@ drop_readahead(PyFileObject *f)
/* Make sure that file has a readahead buffer with at least one byte /* Make sure that file has a readahead buffer with at least one byte
(unless at EOF) and no more than bufsize. Returns negative value on (unless at EOF) and no more than bufsize. Returns negative value on
error */ error, will set MemoryError if bufsize bytes cannot be allocated. */
static int static int
readahead(PyFileObject *f, int bufsize) readahead(PyFileObject *f, int bufsize)
{ {
...@@ -1810,6 +1810,7 @@ readahead(PyFileObject *f, int bufsize) ...@@ -1810,6 +1810,7 @@ readahead(PyFileObject *f, int bufsize)
drop_readahead(f); drop_readahead(f);
} }
if ((f->f_buf = PyMem_Malloc(bufsize)) == NULL) { if ((f->f_buf = PyMem_Malloc(bufsize)) == NULL) {
PyErr_NoMemory();
return -1; return -1;
} }
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment