From a052be4c0d9707ebdb935b8314ed22e8d3d99fc0 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 12 May 2023 18:27:06 +0530 Subject: [PATCH] GH-104371: check return value of calling `mv.release` (#104417) --- Objects/typeobject.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index a1ad5021c4150a..c1525320a7cbd5 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -9158,7 +9158,13 @@ releasebuffer_call_python(PyObject *self, Py_buffer *buffer) Py_DECREF(ret); } if (!is_buffer_wrapper) { - PyObject_CallMethodNoArgs(mv, &_Py_ID(release)); + PyObject *res = PyObject_CallMethodNoArgs(mv, &_Py_ID(release)); + if (res == NULL) { + PyErr_WriteUnraisable(self); + } + else { + Py_DECREF(res); + } } Py_DECREF(mv); end: