Skip to content

Commit

Permalink
Rust: don't leak fd on load_trusted_setup_file() error (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
asn-d6 authored Mar 4, 2024
1 parent 2ab0c21 commit 8758b27
Showing 1 changed file with 2 additions and 3 deletions.
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

0 comments on commit 8758b27

Please sign in to comment.