Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Snape3058 opened this issue Jun 29, 2021 · 0 comments
Assignees
Labels

Comments

@Snape3058
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants