Fix signature of `PyUpb_MessageMeta_Clear` (#17959)

A `tp_clear` function should have signature `int f(PyObject*)`. The presence of erroneous extra parameters leads to undefined behavior as indicated in the C specification 6.3.2.3.8. In WebAssembly builds, this causes crashes. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf#page=60

Closes #17959

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/17959 from hoodmane:fix-message-meta-clear-sig b618f806a9
PiperOrigin-RevId: 669639153
pull/18061/head
Hood Chatham 3 months ago committed by Copybara-Service
parent 2f9e1504a2
commit b915e9f44e
  1. 2
      python/message.c

@ -2025,7 +2025,7 @@ static int PyUpb_MessageMeta_Traverse(PyObject* self, visitproc visit,
return cpython_bits.type_traverse(self, visit, arg); return cpython_bits.type_traverse(self, visit, arg);
} }
static int PyUpb_MessageMeta_Clear(PyObject* self, visitproc visit, void* arg) { static int PyUpb_MessageMeta_Clear(PyObject* self) {
PyUpb_MessageMeta* meta = PyUpb_GetMessageMeta(self); PyUpb_MessageMeta* meta = PyUpb_GetMessageMeta(self);
Py_CLEAR(meta->py_message_descriptor); Py_CLEAR(meta->py_message_descriptor);
return cpython_bits.type_clear(self); return cpython_bits.type_clear(self);

Loading…
Cancel
Save