Skip to content

Commit 94dfbaa

Browse files
committed
Decref the message
1 parent 33cf8b7 commit 94dfbaa

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ CDataType_in_dll_impl(PyObject *type, PyTypeObject *cls, PyObject *dll,
987987
PyObject *message = PyUnicode_DecodeLocale(dlerr, "surrogateescape");
988988
if (message) {
989989
PyErr_SetObject(PyExc_ValueError, message);
990+
Py_DECREF(message);
990991
return NULL;
991992
}
992993
// Ignore errors from PyUnicode_DecodeLocale,
@@ -3813,6 +3814,7 @@ PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
38133814
if (message) {
38143815
PyErr_SetObject(PyExc_AttributeError, message);
38153816
Py_DECREF(ftuple);
3817+
Py_DECREF(message);
38163818
return NULL;
38173819
}
38183820
// Ignore errors from PyUnicode_DecodeLocale,

Modules/_ctypes/callproc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,7 @@ static PyObject *py_dl_sym(PyObject *self, PyObject *args)
16441644
PyObject *message = PyUnicode_DecodeLocale(dlerr, "surrogateescape");
16451645
if (message) {
16461646
PyErr_SetObject(PyExc_OSError, message);
1647+
Py_DECREF(message);
16471648
return NULL;
16481649
}
16491650
// Ignore errors from PyUnicode_DecodeLocale,

0 commit comments

Comments
 (0)