[Python-Dev] Potential NULL pointer dereference in descrobject.c

Michael Mueller mmueller at vigilantsw.com
Sat Dec 17 10:55:55 CET 2011

Hi Guys,

We've been analyzing CPython with our static analysis tool (Sentry)
and a NULL pointer dereference popped up the other day, in

    if (descr != NULL) {
        descr->d_type = type;
        descr->d_name = PyUnicode_InternFromString(name);
        if (descr->d_name == NULL) {
            descr = NULL;
        descr->d_qualname = NULL; // Possible NULL pointer dereference

If the inner conditional block can be reached, descr will be set NULL
and then dereferenced on the next line.  The commented line above was
added in this commit: http://hg.python.org/cpython/rev/73948#l4.92

Hopefully someone can take a look and determine the appropriate fix.


Mike Mueller
Phone: (401) 405-1525
Email: mmueller at vigilantsw.com

Static Analysis for C and C++

More information about the Python-Dev mailing list