Skip to content

Commit 13d31fe

Browse files
committed
fix GC tracking
1 parent edbd446 commit 13d31fe

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Modules/hmacmodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,9 @@ has_uint32_t_buffer_length(const Py_buffer *buffer)
734734
static HMACObject *
735735
hmac_new_object(PyTypeObject *tp)
736736
{
737-
HMACObject *self = (HMACObject *)tp->tp_alloc(tp, 0);
737+
// Using tp_alloc on GC objects automatically tracks them,
738+
// but we need to first set the fields appropriately.
739+
HMACObject *self = PyObject_GC_New(HMACObject, tp);
738740
if (self == NULL) {
739741
return NULL;
740742
}

0 commit comments

Comments
 (0)