diff options
author | Davide Rizzo <sorcio@gmail.com> | 2019-03-06 17:08:31 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2019-03-06 17:08:31 (GMT) |
commit | dc078947a5033a048d804e244e847b5844734439 (patch) | |
tree | a3c4d7a9a785f284baa73ea4823d5c3456bcf4ed /Modules | |
parent | edad38e3e05586ba58291f47756eb3fb808f5577 (diff) | |
download | cpython-dc078947a5033a048d804e244e847b5844734439.zip cpython-dc078947a5033a048d804e244e847b5844734439.tar.gz cpython-dc078947a5033a048d804e244e847b5844734439.tar.bz2 |
bpo-36139: Fix mmap_object_dealloc(): hold the GIL to call PyMem_Free() (GH-12199)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/mmapmodule.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 326288c..6ddbf70 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -117,26 +117,28 @@ typedef struct { static void mmap_object_dealloc(mmap_object *m_obj) { - Py_BEGIN_ALLOW_THREADS #ifdef MS_WINDOWS + Py_BEGIN_ALLOW_THREADS if (m_obj->data != NULL) UnmapViewOfFile (m_obj->data); if (m_obj->map_handle != NULL) CloseHandle (m_obj->map_handle); if (m_obj->file_handle != INVALID_HANDLE_VALUE) CloseHandle (m_obj->file_handle); + Py_END_ALLOW_THREADS if (m_obj->tagname) PyMem_Free(m_obj->tagname); #endif /* MS_WINDOWS */ #ifdef UNIX + Py_BEGIN_ALLOW_THREADS if (m_obj->fd >= 0) (void) close(m_obj->fd); if (m_obj->data!=NULL) { munmap(m_obj->data, m_obj->size); } -#endif /* UNIX */ Py_END_ALLOW_THREADS +#endif /* UNIX */ if (m_obj->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) m_obj); |