diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-08-13 18:10:47 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-08-13 18:10:47 (GMT) |
commit | 3cb31ac704c98fa8a5b9e31a3bd4a8f25bf3d679 (patch) | |
tree | 093a969fe889cb7a53fec93e3cbf57abe00c4a8b /Python/import.c | |
parent | b09f4f578f1e60cf15dde1f5cbdec8a50a9af67b (diff) | |
download | cpython-3cb31ac704c98fa8a5b9e31a3bd4a8f25bf3d679.zip cpython-3cb31ac704c98fa8a5b9e31a3bd4a8f25bf3d679.tar.gz cpython-3cb31ac704c98fa8a5b9e31a3bd4a8f25bf3d679.tar.bz2 |
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
Diffstat (limited to 'Python/import.c')
-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 8ed34bf..da9de8b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -933,7 +933,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); @@ -1232,6 +1233,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), @@ -3044,6 +3047,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; |