Skip to content

Commit 2e63a16

Browse files
emontnemerymattip
authored andcommitted
Ready ThreadCanary_Type
1 parent 61fe449 commit 2e63a16

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/c/misc_thread_common.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ static PyTypeObject ThreadCanary_Type = {
265265

266266
static void init_cffi_tls_zombie(void)
267267
{
268+
/* thread_canary objects are created with PyObject_New(&ThreadCanary_Type);
269+
the type must be readied so it has a valid metatype (ob_type). Otherwise
270+
introspection of a canary from another module dereferences a NULL metatype
271+
and crashes. */
272+
if (PyType_Ready(&ThreadCanary_Type) < 0)
273+
return; /* error set; PyInit__cffi_backend checks PyErr_Occurred() */
274+
268275
cffi_zombie_head.zombie_next = &cffi_zombie_head;
269276
cffi_zombie_head.zombie_prev = &cffi_zombie_head;
270277
cffi_zombie_lock = PyThread_allocate_lock();

0 commit comments

Comments
 (0)