diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-10-05 17:19:30 +0000 |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-10-05 17:19:30 +0000 |
commit | fb369242bdae37e39d9643c312ee5219f2371006 (patch) | |
tree | edb5a122a043de5e706605b90ea954d642a57722 | |
parent | 1af9f68b4a6f8da34481670b9741854081344321 (diff) | |
download | cpython-git-fb369242bdae37e39d9643c312ee5219f2371006.tar.gz |
[Backport r51247 | neal.norwitz]
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
-rw-r--r-- | Python/import.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/import.c b/Python/import.c index fff4b836b8..8776d9a34a 100644 --- a/Python/import.c +++ b/Python/import.c @@ -904,7 +904,8 @@ load_source_module(char *name, char *pathname, FILE *fp) 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); @@ -1194,6 +1195,8 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf, 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), @@ -2827,6 +2830,8 @@ initimp(void) 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; |