]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport r51252 | neal.norwitz]
authorAndrew M. Kuchling <amk@amk.ca>
Tue, 3 Oct 2006 19:39:54 +0000 (19:39 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Tue, 3 Oct 2006 19:39:54 +0000 (19:39 +0000)
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

Modules/zipimport.c

index 2dc504837e8946d41f069b845f15664fbd88e51c..fe552a20758da51a4f1dc0023c50a1f6c588bd30 100644 (file)
@@ -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) {