python / psf-infra-meta

Meta-repository for PSF backed or managed systems. Created mainly for the issue tracker :)
11 stars 7 forks source link

Possible Py_XDECREF in cpython typeobject.h #116

Closed Wesley-Jzy closed 3 years ago

Wesley-Jzy commented 3 years ago

https://github.com/python/cpython/blob/7b21108445969398f6d1db9234fc0fe727565d2e/Objects/typeobject.c#L409

When entering this line, a double Py_XDECREF on mro_meth and type_mro_meth will happen in clear.

Maybe mro_meth and type_mro_meth should be set to NULL after Py_XDECREF like following code. if (custom) { mro_meth = lookup_maybe_method( (PyObject )type, &PyId_mro, &unbound); if (mro_meth == NULL) goto clear; type_mro_meth = lookup_maybe_method( (PyObject )&PyType_Type, &PyId_mro, &unbound); if (type_mro_meth == NULL) goto clear; if (mro_meth != type_mro_meth) goto clear; Py_XDECREF(mro_meth); Py_XDECREF(type_mro_meth); mro_meth = NULL; type_mro_meth = NULL; }