mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
minimize scope for unsafe
update documentation missing check for null
This commit is contained in:
parent
d1820c1516
commit
0c04b54d4d
@ -26,7 +26,7 @@ move_rust_str_to_c_and_free(rust_str_ref_t src, char **dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
log_warn(LD_BUG, "Received a null pointer from caller to protover rust. "
|
log_warn(LD_BUG, "Received a null pointer from caller to rust. "
|
||||||
"This results in a memory leak due to not freeing the rust "
|
"This results in a memory leak due to not freeing the rust "
|
||||||
"string that was meant to be copied..");
|
"string that was meant to be copied..");
|
||||||
return;
|
return;
|
||||||
|
@ -85,7 +85,7 @@ protover_all_supported(const char *s, char **missing_out)
|
|||||||
rust_str_ref_t missing_out_copy = NULL;
|
rust_str_ref_t missing_out_copy = NULL;
|
||||||
int is_supported = rust_protover_all_supported(s, &missing_out_copy);
|
int is_supported = rust_protover_all_supported(s, &missing_out_copy);
|
||||||
|
|
||||||
if (!is_supported) {
|
if (!is_supported && missing_out_copy != NULL) {
|
||||||
move_rust_str_to_c_and_free(missing_out_copy, missing_out);
|
move_rust_str_to_c_and_free(missing_out_copy, missing_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
src/rust/external/external.rs
vendored
2
src/rust/external/external.rs
vendored
@ -24,6 +24,6 @@ pub fn c_tor_version_as_new_as(platform: &str, cutoff: &str) -> bool {
|
|||||||
let result: c_int;
|
let result: c_int;
|
||||||
unsafe {
|
unsafe {
|
||||||
result = tor_version_as_new_as(c_platform.as_ptr(), c_cutoff.as_ptr());
|
result = tor_version_as_new_as(c_platform.as_ptr(), c_cutoff.as_ptr());
|
||||||
|
}
|
||||||
result == 1
|
result == 1
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user