[Python-checkins] r51252 - python/trunk/Modules/zipimport.c

neal.norwitz python-checkins at python.org
Sun Aug 13 20:12:03 CEST 2006


Author: neal.norwitz
Date: Sun Aug 13 20:12:03 2006
New Revision: 51252

Modified:
   python/trunk/Modules/zipimport.c
Log:
It's very unlikely, though possible that source is not a string.  Verify
that PyString_AsString() returns a valid pointer.  (The problem can
arise when zlib.decompress doesn't return a string.)

Klocwork 346



Modified: python/trunk/Modules/zipimport.c
==============================================================================
--- python/trunk/Modules/zipimport.c	(original)
+++ python/trunk/Modules/zipimport.c	Sun Aug 13 20:12:03 2006
@@ -950,6 +950,9 @@
 	char *buf, *q, *p = PyString_AsString(source);
 	PyObject *fixed_source;
 
+	if (!p)
+		return NULL;
+
 	/* one char extra for trailing \n and one for terminating \0 */
 	buf = (char *)PyMem_Malloc(PyString_Size(source) + 2);
 	if (buf == NULL) {


More information about the Python-checkins mailing list