From: Georg Brandl Date: Fri, 31 Mar 2006 20:31:05 +0000 (+0000) Subject: Bug #1177964: make file iterator raise MemoryError on too big files X-Git-Tag: v2.4.4c1~309 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af55db9cd83f82db032190a0e15ad6e8dec11488;p=thirdparty%2FPython%2Fcpython.git Bug #1177964: make file iterator raise MemoryError on too big files (backport from rev. 43506) --- diff --git a/Objects/fileobject.c b/Objects/fileobject.c index c08345c04d39..d7a06942e015 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -1697,7 +1697,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) { @@ -1710,6 +1710,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