]> granicus.if.org Git - python/commitdiff
It's very unlikely, though possible that source is not a string. Verify
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 13 Aug 2006 18:12:03 +0000 (18:12 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 13 Aug 2006 18:12:03 +0000 (18:12 +0000)
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 d59ebd804a8982617c1d8106311884435b5999f4..69b28813c1d00786abe562d121df7f8dfc89e248 100644 (file)
@@ -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) {