Skip to content

Commit

Permalink
Fix PyUpb_Message_MergeInternal segfault (#1338)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
messense committed Sep 7, 2023
1 parent 3dffa71 commit cefa206
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit cefa206

Please sign in to comment.