From b618f806a9c9a7fec79caedb218c32991c2fbf98 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 27 Aug 2024 12:08:26 +0200 Subject: [PATCH] Fix signature of `PyUpb_MessageMeta_Clear` 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 --- python/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/message.c b/python/message.c index c81b43b8dd..5ad1b06ebb 100644 --- a/python/message.c +++ b/python/message.c @@ -2025,7 +2025,7 @@ static int PyUpb_MessageMeta_Traverse(PyObject* self, visitproc visit, 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); Py_CLEAR(meta->py_message_descriptor); return cpython_bits.type_clear(self);