From: Neal Norwitz Date: Sun, 13 Aug 2006 18:12:03 +0000 (+0000) Subject: It's very unlikely, though possible that source is not a string. Verify X-Git-Tag: v2.5c1~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee7c8f9af80ac2fa76987ca25397624915cbaea4;p=python 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 d59ebd804a..69b28813c1 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -950,6 +950,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 = (char *)PyMem_Malloc(PyString_Size(source) + 2); if (buf == NULL) {