mirror of https://github.com/python/cpython
PyModule_GetDict() can fail, produce fatal errors if this happens on startup.
Klocwork #298-299.
This commit is contained in:
parent
b88cfad318
commit
0f7dbf731a
|
@ -203,12 +203,16 @@ Py_InitializeEx(int install_sigs)
|
||||||
if (bimod == NULL)
|
if (bimod == NULL)
|
||||||
Py_FatalError("Py_Initialize: can't initialize __builtin__");
|
Py_FatalError("Py_Initialize: can't initialize __builtin__");
|
||||||
interp->builtins = PyModule_GetDict(bimod);
|
interp->builtins = PyModule_GetDict(bimod);
|
||||||
|
if (interp->builtins == NULL)
|
||||||
|
Py_FatalError("Py_Initialize: can't initialize builtins dict");
|
||||||
Py_INCREF(interp->builtins);
|
Py_INCREF(interp->builtins);
|
||||||
|
|
||||||
sysmod = _PySys_Init();
|
sysmod = _PySys_Init();
|
||||||
if (sysmod == NULL)
|
if (sysmod == NULL)
|
||||||
Py_FatalError("Py_Initialize: can't initialize sys");
|
Py_FatalError("Py_Initialize: can't initialize sys");
|
||||||
interp->sysdict = PyModule_GetDict(sysmod);
|
interp->sysdict = PyModule_GetDict(sysmod);
|
||||||
|
if (interp->sysdict == NULL)
|
||||||
|
Py_FatalError("Py_Initialize: can't initialize sys dict");
|
||||||
Py_INCREF(interp->sysdict);
|
Py_INCREF(interp->sysdict);
|
||||||
_PyImport_FixupExtension("sys", "sys");
|
_PyImport_FixupExtension("sys", "sys");
|
||||||
PySys_SetPath(Py_GetPath());
|
PySys_SetPath(Py_GetPath());
|
||||||
|
|
Loading…
Reference in New Issue