From eea3d23c87fd01a1e25225fd6b2a18a177e420c7 Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 1 Jun 2023 05:52:00 +0000 Subject: [PATCH] Fix `PyUpb_Message_MergeInternal` segfault when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. --- python/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/message.c b/python/message.c index 0e42a9884c..5ddd03b525 100644 --- a/python/message.c +++ b/python/message.c @@ -1202,7 +1202,7 @@ static PyObject* PyUpb_Message_MergeInternal(PyObject* self, PyObject* arg, if (!serialized) return NULL; PyObject* ret = PyUpb_Message_MergeFromString(self, serialized); Py_DECREF(serialized); - Py_DECREF(ret); + Py_XDECREF(ret); Py_RETURN_NONE; }