Skip to content

Commit 8a96071

Browse files
committed
Fix UBSAN positives due to improper XX_dealloc(..) signature in Python modules
1 parent e3a40a8 commit 8a96071

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cpp2py/mako/wrap.cxx

+3-2
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,9 @@ static PyObject* ${c.py_type}_new(PyTypeObject *type, PyObject *args, PyObject *
256256
%endif
257257

258258
// dealloc
259-
static void ${c.py_type}_dealloc(${c.py_type}* self) {
260-
if (self->_c != NULL) delete self->_c; // should never be null, but I protect it anyway
259+
static void ${c.py_type}_dealloc(PyObject* self) {
260+
auto * c_ptr = ((${c.py_type}*)self)->_c;
261+
if (c_ptr != NULL) delete c_ptr; // should never be null, but I protect it anyway
261262
Py_TYPE(self)->tp_free((PyObject*)self);
262263
}
263264

0 commit comments

Comments
 (0)