]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Bug #1177964: make file iterator raise MemoryError on too big files
authorGeorg Brandl <georg@python.org>
Fri, 31 Mar 2006 20:31:05 +0000 (20:31 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 31 Mar 2006 20:31:05 +0000 (20:31 +0000)
 (backport from rev. 43506)

Objects/fileobject.c

index c08345c04d395f69f1c412b296083f5fc2bd366d..d7a06942e015f1d6fa557564828a52266bf50a2b 100644 (file)
@@ -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