diff options
| author | Rubens Brandao <git@rubens.io> | 2024-05-27 10:24:28 -0300 |
|---|---|---|
| committer | Kyle Martin <krm504@nyu.edu> | 2024-05-28 19:06:10 -0400 |
| commit | b3cc03be361d5c6253141e729b096e87e025490f (patch) | |
| tree | 8f89f295033a085a5e86a992b58694cd76a5e3fc /rust/src/types.rs | |
| parent | fce26815b400b5d3c0b67a46085ba8c9a61c1457 (diff) | |
fix multiple memory leaks related to CStr/BnString
Diffstat (limited to 'rust/src/types.rs')
| -rw-r--r-- | rust/src/types.rs | 29 |
1 files changed, 2 insertions, 27 deletions
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<S: BnStrCompatible>(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)) } } } @@ -2718,29 +2716,6 @@ impl<S: BnStrCompatible> DataVariableAndName<S> { } ///////////////////////// -// 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 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] |
