mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
file size.
This commit is contained in:
parent
df37c8c1ad
commit
7fe60c0a0a
5 changed files with 53 additions and 7 deletions
|
@ -896,11 +896,14 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
|
|||
/* on OpenVMS we must ensure that all bytes are written to the file */
|
||||
fsync(fd);
|
||||
# endif
|
||||
if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) &&
|
||||
(size_t)map_size > st.st_size) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"mmap length is greater than file size");
|
||||
return NULL;
|
||||
if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
if (map_size == 0) {
|
||||
map_size = (int)st.st_size;
|
||||
} else if ((size_t)map_size > st.st_size) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"mmap length is greater than file size");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
m_obj = PyObject_New (mmap_object, &mmap_object_type);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue