Skip to content

Commit 58e5c11

Browse files
committed
[Backport r51443 | neal.norwitz]
Handle a few more error conditions. Klocwork 301 and 302. Will backport.
1 parent fec7674 commit 58e5c11

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎Python/pythonrun.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,15 @@ Py_NewInterpreter(void)
497497
bimod = _PyImport_FindExtension("__builtin__", "__builtin__");
498498
if (bimod != NULL) {
499499
interp->builtins = PyModule_GetDict(bimod);
500+
if (interp->builtins == NULL)
501+
goto handle_error;
500502
Py_INCREF(interp->builtins);
501503
}
502504
sysmod = _PyImport_FindExtension("sys", "sys");
503505
if (bimod != NULL && sysmod != NULL) {
504506
interp->sysdict = PyModule_GetDict(sysmod);
507+
if (interp->sysdict == NULL)
508+
goto handle_error;
505509
Py_INCREF(interp->sysdict);
506510
PySys_SetPath(Py_GetPath());
507511
PyDict_SetItemString(interp->sysdict, "modules",
@@ -515,6 +519,7 @@ Py_NewInterpreter(void)
515519
if (!PyErr_Occurred())
516520
return tstate;
517521

522+
handle_error:
518523
/* Oops, it didn't work. Undo it all. */
519524

520525
PyErr_Print();

0 commit comments

Comments
 (0)