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

Rust: Always close fd on load_trusted_setup_file_inner() #402

Merged
merged 1 commit into from
Mar 4, 2024
Merged
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
5 changes: 2 additions & 3 deletions bindings/rust/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ impl KZGSettings {
let mut kzg_settings = MaybeUninit::<KZGSettings>::uninit();
let result = unsafe {
let res = load_trusted_setup_file(kzg_settings.as_mut_ptr(), file_ptr);
let _unchecked_close_result = libc::fclose(file_ptr);

if let C_KZG_RET::C_KZG_OK = res {
Ok(kzg_settings.assume_init())
} else {
Expand All @@ -202,9 +204,6 @@ impl KZGSettings {
}
};

// We don't really care if this fails.
let _unchecked_close_result = unsafe { libc::fclose(file_ptr) };

result
}
}
Expand Down
Loading