Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6eac200

Browse files
committed
Cleanup the previous checkin.
Close the fd in the close method and invalidated it. Don't try to close a second time when deallocating.
1 parent 7b63179 commit 6eac200

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/mmapmodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ mmap_object_dealloc(mmap_object *m_obj)
9999
#endif /* MS_WINDOWS */
100100

101101
#ifdef UNIX
102-
close(m_obj->fd);
102+
if (m_obj->fd >= 0)
103+
(void) close(m_obj->fd);
103104
if (m_obj->data!=NULL) {
104105
msync(m_obj->data, m_obj->size, MS_SYNC);
105106
munmap(m_obj->data, m_obj->size);
@@ -137,6 +138,8 @@ mmap_close_method(mmap_object *self, PyObject *args)
137138
#endif /* MS_WINDOWS */
138139

139140
#ifdef UNIX
141+
(void) close(self->fd);
142+
self->fd = -1;
140143
if (self->data != NULL) {
141144
munmap(self->data, self->size);
142145
self->data = NULL;

0 commit comments

Comments
 (0)