This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author izbyshev
Recipients berker.peksag, izbyshev, serhiy.storchaka
Date 2018-08-25.15:26:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535210800.55.0.56676864532.issue34501@psf.upfronthosting.co.za>
In-reply-to
Content
In the following snippet from PyType_FromSpecWithBases() in Objects/typeobject.c, spec->name is dereferenced by strrchr() but then is checked for NULL:

    /* Set the type name and qualname */
    s = strrchr(spec->name, '.');
    if (s == NULL)
        s = (char*)spec->name;
    else
        s++;

    [snip]

    type->tp_name = spec->name;
    if (!type->tp_name)
        goto fail;

This was reported by Svace static analyzer.

If I were to check spec->name first, what error should I report to the caller? Is something like the following OK?

    if (spec->name == NULL) {
        PyErr_SetString(PyExc_SystemError,
                       "Type spec does not define the name field.");
        goto fail;
    }
History
Date User Action Args
2018-08-25 15:26:40izbyshevsetrecipients: + izbyshev, berker.peksag, serhiy.storchaka
2018-08-25 15:26:40izbyshevsetmessageid: <1535210800.55.0.56676864532.issue34501@psf.upfronthosting.co.za>
2018-08-25 15:26:40izbyshevlinkissue34501 messages
2018-08-25 15:26:40izbyshevcreate