summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorRubens Brandao <git@rubens.io>2024-05-22 13:00:26 -0300
committerMason Reed <mason@vector35.com>2024-07-09 11:04:15 -0400
commit16b31d9bac4dc3c41799f644b18bea433e4e9460 (patch)
treec49880e4a123f492677f0c6528439a33d8bca0a7 /rust/src
parent4b98e88a142c8f1740e564337b30ecadc230cb5a (diff)
Fix double-free with `Array<InstructionTextToken>`
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/disassembly.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs
index e3766f32..5d3da31e 100644
--- a/rust/src/disassembly.rs
+++ b/rust/src/disassembly.rs
@@ -272,28 +272,28 @@ impl Drop for InstructionTextToken {
impl CoreArrayProvider for InstructionTextToken {
type Raw = BNInstructionTextToken;
type Context = ();
- type Wrapped<'a> = Self;
+ type Wrapped<'a> = &'a Self;
}
unsafe impl CoreArrayProviderInner for InstructionTextToken {
unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) {
BNFreeInstructionText(raw, count)
}
unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> {
- Self(*raw)
+ core::mem::transmute(raw)
}
}
impl CoreArrayProvider for Array<InstructionTextToken> {
type Raw = BNInstructionTextLine;
type Context = ();
- type Wrapped<'a> = Self;
+ type Wrapped<'a> = mem::ManuallyDrop<Self>;
}
unsafe impl CoreArrayProviderInner for Array<InstructionTextToken> {
unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) {
BNFreeInstructionTextLines(raw, count)
}
unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> {
- Self::new(raw.tokens, raw.count, ())
+ mem::ManuallyDrop::new(Self::new(raw.tokens, raw.count, ()))
}
}