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

Fix file handle leak in ZipArchive and FileAccessZip #103219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kuruk-mm
Copy link
Contributor

@kuruk-mm kuruk-mm commented Feb 23, 2025

Previously, zfile was stored in a global variable inside the ZipArchive singleton, leading to a potential file handle leak when handling ZIP archives.

Since zfile is not needed at runtime, there is no reason to store it. This change ensures that the file handle is properly closed after processing, preventing unnecessary open file accumulation.

Use case:
I'm developing a game that supports user content with generic file formats (GLB, PNG, and more). We have an Asset Optimization Pipeline that converts these assets into Godot ZIP Packages. When loading thousands of these ZIPs (with ProjectSettings.load_resource_pack), we encountered issues with too many open file handles due to this bug.

This fix ensures that file handles are properly closed, improving resource management and stability when dealing with a large number of ZIP archives.

@kuruk-mm kuruk-mm requested a review from a team as a code owner February 23, 2025 13:51
@kuruk-mm kuruk-mm changed the title Fix: Prevent file handle leak in ZipArchive Fix file handle leak in ZipArchive and FileAccessZip Feb 23, 2025
@Chaosus Chaosus added this to the 4.5 milestone Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants