Skip to content

Conversation

@shindonghwi
Copy link

@shindonghwi shindonghwi commented Dec 19, 2025

Found that extract_zipped_paths() opens a ZipFile but never closes it.

When member is not found and returns early, the ZipFile remains open. Fixed by wrapping with context manager.

# before
zip_file = zipfile.ZipFile(archive)
if member not in zip_file.namelist():
    return path  # leak

# after  
with zipfile.ZipFile(archive) as zip_file:
    if member not in zip_file.namelist():
        return path  # properly closed

Added a test to verify close() is called.

Fix resource leak in extract_zipped_paths() where the ZipFile object
was never properly closed. The function opened a ZipFile but returned
early in multiple code paths without closing it, potentially leaking
file descriptors.

This change wraps the ZipFile usage in a context manager to ensure
proper cleanup regardless of which code path is taken.
@shindonghwi shindonghwi force-pushed the fix/zipfile-resource-leak branch from 95c7552 to 52777ba Compare December 19, 2025 03:13
@shindonghwi shindonghwi reopened this Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant