diff options
| author | Rubens Brandao <git@rubens.io> | 2024-06-04 11:51:15 -0300 |
|---|---|---|
| committer | mason <35282038+emesare@users.noreply.github.com> | 2024-07-03 21:14:02 +0000 |
| commit | fb00f25f16ed1d5453f1531e773db41e77196f2b (patch) | |
| tree | ca2adda9d8fde15fd8fb168d5d5c0d0f883f451a /rust/src/disassembly.rs | |
| parent | 91a64444b1a2544e4d709d72d959715abb6fa661 (diff) | |
fix invalid ptr caused by dropping InstructionTextToken prematurely
Diffstat (limited to 'rust/src/disassembly.rs')
| -rw-r--r-- | rust/src/disassembly.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs index 1fd51cee..e3766f32 100644 --- a/rust/src/disassembly.rs +++ b/rust/src/disassembly.rs @@ -103,6 +103,10 @@ impl InstructionTextToken { mem::transmute(raw) } + pub(crate) fn into_raw(self) -> BNInstructionTextToken { + mem::ManuallyDrop::new(self).0 + } + pub fn new(text: &str, contents: InstructionTextTokenContents) -> Self { let (value, address) = match contents { InstructionTextTokenContents::Integer(v) => (v, 0), @@ -378,7 +382,7 @@ impl From<&Vec<&str>> for DisassemblyTextLine { fn from(string_tokens: &Vec<&str>) -> Self { let mut tokens: Box<[BNInstructionTextToken]> = string_tokens .iter() - .map(|&token| InstructionTextToken::new(token, InstructionTextTokenContents::Text).0) + .map(|&token| InstructionTextToken::new(token, InstructionTextTokenContents::Text).into_raw()) .collect(); // let (tokens_pointer, tokens_len, _) = unsafe { tokens.into_raw_parts() }; // Can't use for now...still a rust nighly feature |
