]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport r51443 | neal.norwitz]
authorAndrew M. Kuchling <amk@amk.ca>
Tue, 3 Oct 2006 19:11:32 +0000 (19:11 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Tue, 3 Oct 2006 19:11:32 +0000 (19:11 +0000)
Handle a few more error conditions.

Klocwork 301 and 302.  Will backport.

Python/pythonrun.c

index 9ef1fea41f69424594a94c77a4d92b2c1bbebfe5..6d6d1d5de3af1ec520f693ffc533ead4a31619fe 100644 (file)
@@ -497,11 +497,15 @@ Py_NewInterpreter(void)
        bimod = _PyImport_FindExtension("__builtin__", "__builtin__");
        if (bimod != NULL) {
                interp->builtins = PyModule_GetDict(bimod);
+               if (interp->builtins == NULL)
+                       goto handle_error;
                Py_INCREF(interp->builtins);
        }
        sysmod = _PyImport_FindExtension("sys", "sys");
        if (bimod != NULL && sysmod != NULL) {
                interp->sysdict = PyModule_GetDict(sysmod);
+               if (interp->sysdict == NULL)
+                       goto handle_error;
                Py_INCREF(interp->sysdict);
                PySys_SetPath(Py_GetPath());
                PyDict_SetItemString(interp->sysdict, "modules",
@@ -515,6 +519,7 @@ Py_NewInterpreter(void)
        if (!PyErr_Occurred())
                return tstate;
 
+handle_error:
        /* Oops, it didn't work.  Undo it all. */
 
        PyErr_Print();