Skip to content

Commit f174256

Browse files
committed
fix double free
1 parent 486c498 commit f174256

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Modules/_operator.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,10 +1594,11 @@ static void * _methodcaller_initialize_vectorcall(methodcallerobject* mc)
15941594
return (void *)1;
15951595
}
15961596

1597-
static _methodcaller_clear_vectorcall(methodcallerobject* mc)
1597+
static void _methodcaller_clear_vectorcall(methodcallerobject* mc)
15981598
{
15991599
if (mc->vectorcall_args != NULL) {
16001600
PyMem_Free(mc->vectorcall_args);
1601+
mc->vectorcall_args = 0;
16011602
Py_CLEAR(mc->vectorcall_kwnames);
16021603
}
16031604
}
@@ -1668,16 +1669,13 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
16681669
return (PyObject *)mc;
16691670
}
16701671

1671-
static int
1672+
static void
16721673
methodcaller_clear(methodcallerobject *mc)
16731674
{
16741675
Py_CLEAR(mc->name);
16751676
Py_CLEAR(mc->xargs);
16761677
Py_CLEAR(mc->kwds);
1677-
16781678
_methodcaller_clear_vectorcall(mc);
1679-
1680-
return 0;
16811679
}
16821680

16831681
static void
@@ -1686,7 +1684,6 @@ methodcaller_dealloc(methodcallerobject *mc)
16861684
PyTypeObject *tp = Py_TYPE(mc);
16871685
PyObject_GC_UnTrack(mc);
16881686
(void)methodcaller_clear(mc);
1689-
PyMem_Free(mc->vectorcall_args);
16901687
tp->tp_free(mc);
16911688
Py_DECREF(tp);
16921689
}

0 commit comments

Comments
 (0)