Skip to content

Commit 67002af

Browse files
author
Victor Stinner
committed
Check error when calling PyUnicode_AppendAndDel()
1 parent 1a15aba commit 67002af

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Modules/_ctypes/callproc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,9 @@ void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...)
944944
else {
945945
PyErr_Clear();
946946
PyUnicode_AppendAndDel(&s, PyUnicode_FromString("???"));
947-
if (s == NULL)
948-
goto error;
949947
}
948+
if (s == NULL)
949+
goto error;
950950
PyErr_SetObject(exc_class, s);
951951
error:
952952
Py_XDECREF(tp);

Python/dynload_win.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname,
187187
HINSTANCE hDLL = NULL;
188188
unsigned int old_mode;
189189
ULONG_PTR cookie = 0;
190-
190+
191191
/* Don't display a message box when Python can't load a DLL */
192192
old_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
193193

@@ -248,8 +248,10 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname,
248248
theInfo,
249249
theLength));
250250
}
251-
PyErr_SetObject(PyExc_ImportError, message);
252-
Py_XDECREF(message);
251+
if (message != NULL) {
252+
PyErr_SetObject(PyExc_ImportError, message);
253+
Py_DECREF(message);
254+
}
253255
return NULL;
254256
} else {
255257
char buffer[256];

0 commit comments

Comments
 (0)