diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-10-23 19:17:48 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-10-23 19:17:48 -0400 |
commit | 169bc670ddf9fe898800a2814a1ec30dcc3249da (patch) | |
tree | 05e4eb35e45557edcf619be0e138bfd17a3611bd /src | |
parent | 93fd924bdb8d47a8ee4074dfffaf568320372165 (diff) | |
parent | 42558df7c8affeec33e66d987ccf4d632a9d5466 (diff) | |
download | tor-169bc670ddf9fe898800a2814a1ec30dcc3249da.tar.gz tor-169bc670ddf9fe898800a2814a1ec30dcc3249da.zip |
Merge remote-tracking branch 'onionk/rust-allsupportednull1' into maint-0.3.3
Diffstat (limited to 'src')
-rw-r--r-- | src/rust/protover/ffi.rs | 10 | ||||
-rw-r--r-- | src/test/test_protover.c | 1 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/rust/protover/ffi.rs b/src/rust/protover/ffi.rs index 9656e8c318..8ab11842d1 100644 --- a/src/rust/protover/ffi.rs +++ b/src/rust/protover/ffi.rs @@ -68,12 +68,10 @@ pub extern "C" fn protover_all_supported( if maybe_unsupported.is_some() { let unsupported: UnvalidatedProtoEntry = maybe_unsupported.unwrap(); - let c_unsupported: CString = match CString::new(unsupported.to_string()) { - Ok(n) => n, - Err(_) => return 1, - }; - - let ptr = c_unsupported.into_raw(); + if missing_out.is_null() { + return 0; + } + let ptr = allocate_and_copy_string(&unsupported.to_string()); unsafe { *missing_out = ptr }; return 0; diff --git a/src/test/test_protover.c b/src/test/test_protover.c index 026ae2ddd8..bdfb2d13cd 100644 --- a/src/test/test_protover.c +++ b/src/test/test_protover.c @@ -259,6 +259,7 @@ test_protover_all_supported(void *arg) tt_ptr_op(msg, OP_EQ, NULL); // Some things we don't support + tt_assert(! protover_all_supported("Wombat=9", NULL)); tt_assert(! protover_all_supported("Wombat=9", &msg)); tt_str_op(msg, OP_EQ, "Wombat=9"); tor_free(msg); |