summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-03-31 20:31:02 (GMT)
committerGeorg Brandl <georg@python.org>2006-03-31 20:31:02 (GMT)
commited02eb6aa99ea27f57d0a3c303d8e825d8ef6d9c (patch)
tree71c9cccd5bf07e77e70ec0019cbffb32897ad4f5 /Objects/fileobject.c
parent644b1e7aac8f048ade4709f248c4d66b85800efc (diff)
downloadcpython-ed02eb6aa99ea27f57d0a3c303d8e825d8ef6d9c.zip
cpython-ed02eb6aa99ea27f57d0a3c303d8e825d8ef6d9c.tar.gz
cpython-ed02eb6aa99ea27f57d0a3c303d8e825d8ef6d9c.tar.bz2
Bug #1177964: make file iterator raise MemoryError on too big files
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 29c89db..5a50d1e 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -1797,7 +1797,7 @@ drop_readahead(PyFileObject *f)
/* 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
- error */
+ error, will set MemoryError if bufsize bytes cannot be allocated. */
static int
readahead(PyFileObject *f, int bufsize)
{
@@ -1810,6 +1810,7 @@ readahead(PyFileObject *f, int bufsize)
drop_readahead(f);
}
if ((f->f_buf = PyMem_Malloc(bufsize)) == NULL) {
+ PyErr_NoMemory();
return -1;
}
Py_BEGIN_ALLOW_THREADS