Kaydet (Commit) dc078947 authored tarafından Davide Rizzo's avatar Davide Rizzo Kaydeden (comit) Victor Stinner

bpo-36139: Fix mmap_object_dealloc(): hold the GIL to call PyMem_Free() (GH-12199)

üst edad38e3
...@@ -117,26 +117,28 @@ typedef struct { ...@@ -117,26 +117,28 @@ typedef struct {
static void static void
mmap_object_dealloc(mmap_object *m_obj) mmap_object_dealloc(mmap_object *m_obj)
{ {
Py_BEGIN_ALLOW_THREADS
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
Py_BEGIN_ALLOW_THREADS
if (m_obj->data != NULL) if (m_obj->data != NULL)
UnmapViewOfFile (m_obj->data); UnmapViewOfFile (m_obj->data);
if (m_obj->map_handle != NULL) if (m_obj->map_handle != NULL)
CloseHandle (m_obj->map_handle); CloseHandle (m_obj->map_handle);
if (m_obj->file_handle != INVALID_HANDLE_VALUE) if (m_obj->file_handle != INVALID_HANDLE_VALUE)
CloseHandle (m_obj->file_handle); CloseHandle (m_obj->file_handle);
Py_END_ALLOW_THREADS
if (m_obj->tagname) if (m_obj->tagname)
PyMem_Free(m_obj->tagname); PyMem_Free(m_obj->tagname);
#endif /* MS_WINDOWS */ #endif /* MS_WINDOWS */
#ifdef UNIX #ifdef UNIX
Py_BEGIN_ALLOW_THREADS
if (m_obj->fd >= 0) if (m_obj->fd >= 0)
(void) close(m_obj->fd); (void) close(m_obj->fd);
if (m_obj->data!=NULL) { if (m_obj->data!=NULL) {
munmap(m_obj->data, m_obj->size); munmap(m_obj->data, m_obj->size);
} }
#endif /* UNIX */
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
#endif /* UNIX */
if (m_obj->weakreflist != NULL) if (m_obj->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) m_obj); PyObject_ClearWeakRefs((PyObject *) m_obj);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment