Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 39468:57482176e101 legacy-trunk
cpathname could be NULL if it was longer than MAXPATHLEN. Don't try
to write the .pyc to NULL.
Check results of PyList_GetItem() and PyModule_GetDict() are not NULL.
Klocwork 282, 283, 285
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sun, 13 Aug 2006 18:10:47 +0000 |
| parents | 75bf77367da3 |
| children | 8dcb882ec3e1 |
line wrap: on
line diff
--- a/Python/import.c Sun Aug 13 18:10:28 2006 +0000 +++ b/Python/import.c Sun Aug 13 18:10:47 2006 +0000 @@ -933,7 +933,8 @@ if (Py_VerboseFlag) PySys_WriteStderr("import %s # from %s\n", name, pathname); - write_compiled_module(co, cpathname, mtime); + if (cpathname) + write_compiled_module(co, cpathname, mtime); } m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname); Py_DECREF(co); @@ -1232,6 +1233,8 @@ for (i = 0; i < npath; i++) { PyObject *copy = NULL; PyObject *v = PyList_GetItem(path, i); + if (!v) + return NULL; #ifdef Py_USING_UNICODE if (PyUnicode_Check(v)) { copy = PyUnicode_Encode(PyUnicode_AS_UNICODE(v), @@ -3044,6 +3047,8 @@ if (m == NULL) goto failure; d = PyModule_GetDict(m); + if (d == NULL) + goto failure; if (setint(d, "SEARCH_ERROR", SEARCH_ERROR) < 0) goto failure; if (setint(d, "PY_SOURCE", PY_SOURCE) < 0) goto failure;
