From: Andrew M. Kuchling Date: Tue, 3 Oct 2006 19:39:54 +0000 (+0000) Subject: [Backport r51252 | neal.norwitz] X-Git-Tag: v2.4.4c1~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=397935f4a3eb55810478910e4a0443f1fcb5bcb5;p=thirdparty%2FPython%2Fcpython.git [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 --- diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 2dc504837e89..fe552a20758d 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -955,6 +955,9 @@ normalize_line_endings(PyObject *source) 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) {