Skip to content

[BUG] Four potential memory leaks due to refcnt not decreased on error branches. (Static analysis reports) #383

Open
@Snape3058

Description

@Snape3058

Describe the bug
During module initialization, the call to macro import_array will return NULL directly on failure, which will make the created module leaked without decreasing its refcnt.

Bug path trace

move_template.c

  1. Module is created, pointed to by m.

    PyObject *m = PyModule_Create(&move_def);

  2. Assume m is not NULL.

    if (m == NULL) return RETVAL;

  3. Invoke macro import_array, assume error happens and NULL is returned directly.

    import_array();

  4. The module pointed to by m leaks without decreasing its refcnt.

Similarly, it is the same symptom in another three files.

Version

Static analysis carried out on commit f2bc792.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions