Skip to content

Module object leaked on import_array/intern_strings failure in all PyInit functions #530

@devdanzin

Description

@devdanzin

In all four PyInit_*\ functions, the module object mis created viaPyModule_Create, then import_array()andintern_strings()are called. If either fails, the function returns NULL withoutPy_DECREF(m)`, leaking the module object.

The import_array() case is particularly tricky because the NumPy macro expands to a bare return NULL that cannot be intercepted. Using _import_array() (which returns an int error code) would allow proper cleanup.

File(s): reduce_template.c:1974-1975, move_template.c:1543-1544, nonreduce_template.c:355-356, nonreduce_axis_template.c:1035-1036

See #518 for the complete report.

Found using cext-review-toolkit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions