Skip to content

Remove check on strong_count < 1. #32

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

Merged
merged 1 commit into from
Feb 3, 2021
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
16 changes: 4 additions & 12 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,10 @@ pub extern "C" fn rustls_client_config_builder_load_roots_from_file(
pub extern "C" fn rustls_client_config_free(config: *const rustls_client_config) {
ffi_panic_boundary_unit! {
let config: &ClientConfig = try_ref_from_ptr!(config, &mut ClientConfig, ());
// To free the client_config, we reconstruct the Arc. It should have a refcount of 1,
// representing the C code's copy. When it drops, that refcount will go down to 0
// and the inner ClientConfig will be dropped.
let arc: Arc<ClientConfig> = unsafe { Arc::from_raw(config) };
let strong_count = Arc::strong_count(&arc);
if strong_count < 1 {
eprintln!(
"rustls_client_config_free: invariant failed: arc.strong_count was < 1: {}. \
You must not free the same client_config multiple times.",
strong_count
);
}
// To free the client_config, we reconstruct the Arc and then drop it. It should
// have a refcount of 1, representing the C code's copy. When it drops, that
// refcount will go down to 0 and the inner ClientConfig will be dropped.
unsafe { drop(Arc::from_raw(config)) };
}
}

Expand Down