From ccadaf3196bda975dec5ed2aac8a78e75ab51c1b 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. --- upb/python/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upb/python/message.c b/upb/python/message.c index 7c8ddebce1..5a96980578 100644 --- a/upb/python/message.c +++ b/upb/python/message.c @@ -1216,7 +1216,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; }