[Python-checkins] r52120 - python/branches/release24-maint/Modules/zipimport.c

andrew.kuchling python-checkins at python.org
Tue Oct 3 21:39:54 CEST 2006


Author: andrew.kuchling
Date: Tue Oct  3 21:39:54 2006
New Revision: 52120

Modified:
   python/branches/release24-maint/Modules/zipimport.c
Log:
[Backport r51252 | neal.norwitz]

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/branches/release24-maint/Modules/zipimport.c
==============================================================================
--- python/branches/release24-maint/Modules/zipimport.c	(original)
+++ python/branches/release24-maint/Modules/zipimport.c	Tue Oct  3 21:39:54 2006
@@ -955,6 +955,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 = PyMem_Malloc(PyString_Size(source) + 2);
 	if (buf == NULL) {


More information about the Python-checkins mailing list