[tor-commits] [tor/master] minimize scope for unsafe
nickm at torproject.org
nickm at torproject.org
Fri Oct 27 14:07:25 UTC 2017
commit 0c04b54d4d78f7f3117948358b3d05e644fa1aeb
Author: Chelsea Holland Komlo <me at chelseakomlo.com>
Date: Thu Sep 28 03:08:37 2017 +0000
minimize scope for unsafe
update documentation
missing check for null
---
src/common/rust_types.c | 2 +-
src/or/protover_rust.c | 2 +-
src/rust/external/external.rs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/common/rust_types.c b/src/common/rust_types.c
index d116b515b..1b6dd3990 100644
--- a/src/common/rust_types.c
+++ b/src/common/rust_types.c
@@ -26,7 +26,7 @@ move_rust_str_to_c_and_free(rust_str_ref_t src, char **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 "
"string that was meant to be copied..");
return;
diff --git a/src/or/protover_rust.c b/src/or/protover_rust.c
index ebe815357..261555d1e 100644
--- a/src/or/protover_rust.c
+++ b/src/or/protover_rust.c
@@ -85,7 +85,7 @@ protover_all_supported(const char *s, char **missing_out)
rust_str_ref_t missing_out_copy = NULL;
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);
}
diff --git a/src/rust/external/external.rs b/src/rust/external/external.rs
index 0e8d1eb0d..f3267949c 100644
--- a/src/rust/external/external.rs
+++ b/src/rust/external/external.rs
@@ -24,6 +24,6 @@ pub fn c_tor_version_as_new_as(platform: &str, cutoff: &str) -> bool {
let result: c_int;
unsafe {
result = tor_version_as_new_as(c_platform.as_ptr(), c_cutoff.as_ptr());
- result == 1
}
+ result == 1
}
More information about the tor-commits
mailing list