]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Check error when calling PyUnicode_AppendAndDel()
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 2 Oct 2011 18:35:10 +0000 (20:35 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 2 Oct 2011 18:35:10 +0000 (20:35 +0200)
Modules/_ctypes/callproc.c
Python/dynload_win.c

index 5a5ce31cbf3ac8a744e326e203fd9b7fcc49a84f..60d59c878a59163a379086c3722fc53c908ba6da 100644 (file)
@@ -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);
index 932a637680de0c006029d7cccdf41b4e97f38c42..c620e58948e7df427921ca81dee31bc6e8a79dd0 100644 (file)
@@ -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];