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

zip_close failed cause filesystem handle to leak. #417

Closed
Johnxjj opened this issue Nov 15, 2023 · 3 comments
Closed

zip_close failed cause filesystem handle to leak. #417

Johnxjj opened this issue Nov 15, 2023 · 3 comments
Labels
bug libzip doesn't behave as expected.

Comments

@Johnxjj
Copy link

Johnxjj commented Nov 15, 2023

I see that zip_close fails, it fails to return from here:
if (_zip_read_local_ef(za, i) < 0) {
error = 1;
break;
}
then return,
if (error) {
zip_source_rollback_write(za->src);
return -1;
}
and I observe that it does not close the zip file, this cause my filesystem handle to leak.

@Johnxjj Johnxjj added the bug libzip doesn't behave as expected. label Nov 15, 2023
@Johnxjj
Copy link
Author

Johnxjj commented Nov 15, 2023

I'm not familiar with libzip, is that because of the way I use it?

@dillof
Copy link
Member

dillof commented Nov 15, 2023

As stated in the documentation:

If successful, archive is freed. Otherwise archive is left unchanged and must still be freed.

So, in case of error, you have to call zip_discard() to close the archive.

@dillof dillof closed this as completed Nov 15, 2023
@Johnxjj
Copy link
Author

Johnxjj commented Nov 15, 2023

Thank you very much for your reply, it helped me a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug libzip doesn't behave as expected.
Projects
None yet
Development

No branches or pull requests

2 participants