diff Python/import.c @ 40007:1f588a982cc5 2.4

[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
author Andrew M. Kuchling <amk@amk.ca>
date Thu, 05 Oct 2006 17:19:30 +0000
parents de7c0cb5a872
children ab13576374b1
line wrap: on
line diff
--- a/Python/import.c	Thu Oct 05 17:18:13 2006 +0000
+++ b/Python/import.c	Thu Oct 05 17:19:30 2006 +0000
@@ -904,7 +904,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);
@@ -1194,6 +1195,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),
@@ -2827,6 +2830,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;