Skip to content

Leaked file descriptor in Python/import.c #142776

@stratakis

Description

@stratakis

Bug report

Bug description:

Hello,

Our internal coverity scan instance identified two code paths which leak a file descriptor in import.c in the _imp_create_dynamic_impl function:

https://github.com/python/cpython/blame/bef63d2fb81ae28760040157ea589541bed47d02/Python/import.c#L4820-L4829

https://github.com/python/cpython/blame/bef63d2fb81ae28760040157ea589541bed47d02/Python/import.c#L4842-L4844

If goto finally is reached fp will remain open.

There is also a related comment on the cleanup block:
https://github.com/python/cpython/blame/bef63d2fb81ae28760040157ea589541bed47d02/Python/import.c#L4849

CPython versions tested on:

3.15, 3.14, 3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions