mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
rust/protover: return C-allocated string in protover_all_supported()
The result of CString::into_raw() is not safe to free
with free() except under finicky and fragile circumstances
that we definitely don't meet right now.
This was missed in be583a34a3
.
This commit is contained in:
parent
db89b4b152
commit
42558df7c8
4
changes/bug27740
Normal file
4
changes/bug27740
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
o Minor bugfixes (rust):
|
||||||
|
- Return a string that can be safely freed by C code, not one created by
|
||||||
|
the rust allocator, in protover_all_supported(). Fixes bug 27740; bugfix
|
||||||
|
on 0.3.3.1-alpha.
|
@ -71,12 +71,7 @@ pub extern "C" fn protover_all_supported(
|
|||||||
if missing_out.is_null() {
|
if missing_out.is_null() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
let c_unsupported: CString = match CString::new(unsupported.to_string()) {
|
let ptr = allocate_and_copy_string(&unsupported.to_string());
|
||||||
Ok(n) => n,
|
|
||||||
Err(_) => return 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
let ptr = c_unsupported.into_raw();
|
|
||||||
unsafe { *missing_out = ptr };
|
unsafe { *missing_out = ptr };
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user