From cefa206f546ce36f895cd02ab5a7e8a1f6918a22 Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 8 Sep 2023 00:28:54 +0800 Subject: [PATCH] Fix `PyUpb_Message_MergeInternal` segfault (#1338) 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 8c66ff733..8e0447f16 100644 --- a/python/message.c +++ b/python/message.c @@ -1208,7 +1208,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; }