Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix memory leaks.
  • Loading branch information
ericsnowcurrently committed Mar 15, 2019
commit 89e01f28abcb6c2b20560cbd388633f892f851b9
6 changes: 5 additions & 1 deletion Modules/_xxsubinterpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ struct _sharednsitem {
_PyCrossInterpreterData data;
};

static void _sharednsitem_clear(struct _sharednsitem *); // forward

static int
_sharednsitem_init(struct _sharednsitem *item, PyObject *key, PyObject *value)
{
Expand All @@ -79,6 +81,7 @@ _sharednsitem_init(struct _sharednsitem *item, PyObject *key, PyObject *value)
return -1;
}
if (_PyObject_GetCrossInterpreterData(value, &item->data) != 0) {
_sharednsitem_clear(item);
return -1;
}
return 0;
Expand All @@ -89,6 +92,7 @@ _sharednsitem_clear(struct _sharednsitem *item)
{
if (item->name != NULL) {
PyMem_Free(item->name);
item->name = NULL;
}
_PyCrossInterpreterData_Release(&item->data);
}
Expand Down Expand Up @@ -1339,8 +1343,8 @@ _channel_send(_channels *channels, int64_t id, PyObject *obj)
return -1;
}
if (_PyObject_GetCrossInterpreterData(obj, data) != 0) {
PyMem_Free(data);
PyThread_release_lock(mutex);
PyMem_Free(data);
return -1;
}

Expand Down