]> granicus.if.org Git - python/commitdiff
Bug #1177964: make file iterator raise MemoryError on too big files
authorGeorg Brandl <georg@python.org>
Fri, 31 Mar 2006 20:31:02 +0000 (20:31 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 31 Mar 2006 20:31:02 +0000 (20:31 +0000)
Objects/fileobject.c

index 29c89db52feb7ee8b06db8d28e437315776bd2f3..5a50d1ee32f47d047faa32f96c6d438de0bfaf49 100644 (file)
@@ -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