From: Victor Stinner Date: Sun, 2 Oct 2011 18:35:10 +0000 (+0200) Subject: Check error when calling PyUnicode_AppendAndDel() X-Git-Tag: v3.3.0a1~1390 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67002af32309be6f3a484b4f47f1a1551a57ee6e;p=thirdparty%2FPython%2Fcpython.git Check error when calling PyUnicode_AppendAndDel() --- diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 5a5ce31cbf3a..60d59c878a59 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -944,9 +944,9 @@ void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...) else { PyErr_Clear(); PyUnicode_AppendAndDel(&s, PyUnicode_FromString("???")); - if (s == NULL) - goto error; } + if (s == NULL) + goto error; PyErr_SetObject(exc_class, s); error: Py_XDECREF(tp); diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 932a637680de..c620e58948e7 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -187,7 +187,7 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, HINSTANCE hDLL = NULL; unsigned int old_mode; ULONG_PTR cookie = 0; - + /* Don't display a message box when Python can't load a DLL */ old_mode = SetErrorMode(SEM_FAILCRITICALERRORS); @@ -248,8 +248,10 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, theInfo, theLength)); } - PyErr_SetObject(PyExc_ImportError, message); - Py_XDECREF(message); + if (message != NULL) { + PyErr_SetObject(PyExc_ImportError, message); + Py_DECREF(message); + } return NULL; } else { char buffer[256];