diff options
author | Bénédikt Tran <10796600+picnixz@users.noreply.github.com> | 2025-01-06 11:50:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-06 11:50:01 (GMT) |
commit | 1ef6bf4e29db43bbf06639923516838db2d5a5ba (patch) | |
tree | 18b1e3a80bc7a772b8b0235ac9ecf4c8c3276248 /Objects | |
parent | 8d15058d61681e98579cf3fbd3c6fd13b3df6a72 (diff) | |
download | cpython-1ef6bf4e29db43bbf06639923516838db2d5a5ba.zip cpython-1ef6bf4e29db43bbf06639923516838db2d5a5ba.tar.gz cpython-1ef6bf4e29db43bbf06639923516838db2d5a5ba.tar.bz2 |
gh-111178: fix UBSan failures in `Objects/descrobject.c` (GH-128245)
fix UBSan failures for `propertyobject`
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/descrobject.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 4eccd17..1852118 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1508,6 +1508,8 @@ PyWrapper_New(PyObject *d, PyObject *self) /* A built-in 'property' type */ +#define _propertyobject_CAST(op) ((propertyobject *)(op)) + /* class property(object): @@ -1911,8 +1913,9 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset, } static PyObject * -property_get__name__(propertyobject *prop, void *Py_UNUSED(ignored)) +property_get__name__(PyObject *op, void *Py_UNUSED(ignored)) { + propertyobject *prop = _propertyobject_CAST(op); PyObject *name; if (property_name(prop, &name) < 0) { return NULL; @@ -1925,16 +1928,17 @@ property_get__name__(propertyobject *prop, void *Py_UNUSED(ignored)) } static int -property_set__name__(propertyobject *prop, PyObject *value, - void *Py_UNUSED(ignored)) +property_set__name__(PyObject *op, PyObject *value, void *Py_UNUSED(ignored)) { + propertyobject *prop = _propertyobject_CAST(op); Py_XSETREF(prop->prop_name, Py_XNewRef(value)); return 0; } static PyObject * -property_get___isabstractmethod__(propertyobject *prop, void *closure) +property_get___isabstractmethod__(PyObject *op, void *closure) { + propertyobject *prop = _propertyobject_CAST(op); int res = _PyObject_IsAbstract(prop->prop_get); if (res == -1) { return NULL; @@ -1962,9 +1966,8 @@ property_get___isabstractmethod__(propertyobject *prop, void *closure) } static PyGetSetDef property_getsetlist[] = { - {"__name__", (getter)property_get__name__, (setter)property_set__name__}, - {"__isabstractmethod__", - (getter)property_get___isabstractmethod__, NULL, + {"__name__", property_get__name__, property_set__name__, NULL, NULL}, + {"__isabstractmethod__", property_get___isabstractmethod__, NULL, NULL, NULL}, {NULL} /* Sentinel */ |