From 3e444f221b4dfc37497342686732ba10dbcfa567 Mon Sep 17 00:00:00 2001 From: Rubens Brandao Date: Wed, 17 Apr 2024 09:53:45 -0300 Subject: [PATCH] fix leak creation of invalid BinaryView handle --- rust/src/interaction.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/src/interaction.rs b/rust/src/interaction.rs index ccb5c81a41..76fc92752c 100644 --- a/rust/src/interaction.rs +++ b/rust/src/interaction.rs @@ -296,7 +296,9 @@ impl FormInputBuilder { result.type_ = BNFormInputFieldType::AddressFormField; result.prompt = prompt.as_ref().as_ptr() as *const c_char; if let Some(view) = view { - result.view = view.handle; + // the view is being moved into result, there is no need to clone + // and drop is intentionally being avoided with `Ref::into_raw` + result.view = unsafe { Ref::into_raw(view) }.handle; } result.currentAddress = current_address.unwrap_or(0); result.hasDefault = default.is_some();