File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1298,6 +1298,7 @@ _release_xidata(void *arg)
1298
1298
data -> free (data -> data );
1299
1299
}
1300
1300
Py_XDECREF (data -> obj );
1301
+ PyMem_Free (data );
1301
1302
return 0 ;
1302
1303
}
1303
1304
@@ -1318,14 +1319,22 @@ _PyCrossInterpreterData_Release(_PyCrossInterpreterData *data)
1318
1319
}
1319
1320
return ;
1320
1321
}
1321
- // XXX There's a slight race here...
1322
+ // XXX There's an ever-so- slight race here...
1322
1323
if (interp -> finalizing ) {
1323
1324
// XXX Someone leaked some memory...
1324
1325
return ;
1325
1326
}
1326
1327
1327
1328
// "Release" the data and/or the object.
1328
- if (_Py_AddPendingCall (interp , 0 , _release_xidata , data ) != 0 ) {
1329
+ _PyCrossInterpreterData * copied = PyMem_Malloc (sizeof (_PyCrossInterpreterData ));
1330
+ if (copied == NULL ) {
1331
+ PyErr_SetString (PyExc_MemoryError ,
1332
+ "Not enough memory to preserve cross-interpreter data" );
1333
+ PyErr_Print ();
1334
+ return ;
1335
+ }
1336
+ memcpy (copied , data , sizeof (_PyCrossInterpreterData ));
1337
+ if (_Py_AddPendingCall (interp , 0 , _release_xidata , copied ) != 0 ) {
1329
1338
// XXX Queue full or couldn't get lock. Try again somehow?
1330
1339
}
1331
1340
}
You can’t perform that action at this time.
0 commit comments