diff --git a/src/client.rs b/src/client.rs index 0fbe1424..665a8b48 100644 --- a/src/client.rs +++ b/src/client.rs @@ -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 = 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)) }; } }