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/hlil/operation.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'rust/src/hlil/operation.rs') diff --git a/rust/src/hlil/operation.rs b/rust/src/hlil/operation.rs index ee0d437b..e762a74b 100644 --- a/rust/src/hlil/operation.rs +++ b/rust/src/hlil/operation.rs @@ -1,8 +1,10 @@ use binaryninjacore_sys::BNGetGotoLabelName; +use crate::architecture::CoreIntrinsic; use crate::function::Function; use crate::rc::Ref; -use crate::types::{ConstantData, ILIntrinsic, SSAVariable, Variable}; +use crate::string::BnString; +use crate::types::{ConstantData, SSAVariable, Variable}; use super::HighLevelILLiftedInstruction; @@ -13,10 +15,8 @@ pub struct GotoLabel { } impl GotoLabel { - pub fn name(&self) -> &str { - let raw_str = unsafe { BNGetGotoLabelName(self.function.handle, self.target) }; - let c_str = unsafe { core::ffi::CStr::from_ptr(raw_str) }; - c_str.to_str().unwrap() + pub fn name(&self) -> BnString { + unsafe { BnString::from_raw(BNGetGotoLabelName(self.function.handle, self.target)) } } } @@ -320,7 +320,7 @@ pub struct Intrinsic { } #[derive(Clone, Debug, PartialEq)] pub struct LiftedIntrinsic { - pub intrinsic: ILIntrinsic, + pub intrinsic: CoreIntrinsic, pub params: Vec, } @@ -335,7 +335,7 @@ pub struct IntrinsicSsa { } #[derive(Clone, Debug, PartialEq)] pub struct LiftedIntrinsicSsa { - pub intrinsic: ILIntrinsic, + pub intrinsic: CoreIntrinsic, pub params: Vec, pub dest_memory: u64, pub src_memory: u64, -- cgit v1.3.1