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 leaking file descriptors with zip pack files #40303

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/io/file_access_zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ static void *godot_open(void *data, const char *p_fname, int mode) {
}

FileAccess *f = (FileAccess *)data;
f->open(p_fname, FileAccess::READ);
if (!f->is_open()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if a file is already open? Won't it fail opening the new file as requested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear if it wants to open a different file. We might want to compare the file paths to make sure.

The integration of FileAccess with the uzip lib isn't super clean. It seems like uzip doesn't want to start with an open file, just enough information to do it on its own. But we give it a FileAccess::open anyway. uzip then called the open callback godot_open to open the file, even though we gave it to uzip already opened. godot_open then calls FileAccess::open again and seems to leave it dangling. 😬

We might want to consider starting uzip with FileAccess::create and then call reopen unguarded.

f->reopen(p_fname, FileAccess::READ);
}

return f->is_open() ? data : nullptr;
}
Expand Down