Skip to content

Commit 977188c

Browse files
committed
Fix memory leak.
1 parent ec1c5cc commit 977188c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

peps/pep-0788.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,13 +861,14 @@ deadlock the interpreter if it's not released.
861861
{
862862
// Weak reference to the interpreter. It won't wait on the callback
863863
// to finalize.
864-
ThreadData *tdata = PyMem_Malloc(sizeof(ThreadData));
864+
ThreadData *tdata = PyMem_RawMalloc(sizeof(ThreadData));
865865
if (tdata == NULL) {
866866
PyErr_NoMemory();
867867
return NULL;
868868
}
869869
PyInterpreterWeakRef wref;
870870
if (PyInterpreterWeakRef_Get(&wref) < 0) {
871+
PyMem_RawFree(tdata);
871872
return NULL;
872873
}
873874
tdata->wref = wref;

0 commit comments

Comments
 (0)