From b3cc03be361d5c6253141e729b096e87e025490f Mon Sep 17 00:00:00 2001 From: Rubens Brandao Date: Mon, 27 May 2024 10:24:28 -0300 Subject: fix multiple memory leaks related to CStr/BnString --- rust/src/types.rs | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'rust/src/types.rs') diff --git a/rust/src/types.rs b/rust/src/types.rs index 1a591801..7adc449e 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -1194,11 +1194,9 @@ impl Type { } } - pub fn generate_auto_demangled_type_id<'a, S: BnStrCompatible>(name: S) -> &'a str { + pub fn generate_auto_demangled_type_id(name: S) -> BnString { let mut name = QualifiedName::from(name); - unsafe { CStr::from_ptr(BNGenerateAutoDemangledTypeId(&mut name.0)) } - .to_str() - .unwrap() + unsafe { BnString::from_raw(BNGenerateAutoDemangledTypeId(&mut name.0)) } } } @@ -2717,29 +2715,6 @@ impl DataVariableAndName { } } -///////////////////////// -// ILIntrinsic - -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct ILIntrinsic { - arch: CoreArchitecture, - index: u32, -} - -impl ILIntrinsic { - pub(crate) fn new(arch: CoreArchitecture, index: u32) -> Self { - Self { arch, index } - } - - pub fn name(&self) -> &str { - let name_ptr = unsafe { BNGetArchitectureIntrinsicName(self.arch.0, self.index) }; - let name_raw = unsafe { core::ffi::CStr::from_ptr(name_ptr) }; - name_raw.to_str().unwrap() - } - - // TODO impl inputs and outputs function -} - ///////////////////////// // RegisterValueType -- cgit v1.3.1