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/symbol.rs | |
| parent | fce26815b400b5d3c0b67a46085ba8c9a61c1457 (diff) | |
fix multiple memory leaks related to CStr/BnString
Diffstat (limited to 'rust/src/symbol.rs')
| -rw-r--r-- | rust/src/symbol.rs | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/rust/src/symbol.rs b/rust/src/symbol.rs index f022fd3f..d7a73a0a 100644 --- a/rust/src/symbol.rs +++ b/rust/src/symbol.rs @@ -14,7 +14,6 @@ //! Interfaces for the various kinds of symbols in a binary. -use std::ffi::CStr; use std::fmt; use std::hash::{Hash, Hasher}; use std::ptr; @@ -249,24 +248,15 @@ impl Symbol { } pub fn full_name(&self) -> BnString { - unsafe { - let name = BNGetSymbolFullName(self.handle); - BnString::from_raw(name) - } + unsafe { BnString::from_raw(BNGetSymbolFullName(self.handle)) } } - pub fn short_name(&self) -> &str { - unsafe { - let name = BNGetSymbolShortName(self.handle); - CStr::from_ptr(name).to_str().unwrap() - } + pub fn short_name(&self) -> BnString { + unsafe { BnString::from_raw(BNGetSymbolShortName(self.handle)) } } - pub fn raw_name(&self) -> &str { - unsafe { - let name = BNGetSymbolRawName(self.handle); - CStr::from_ptr(name).to_str().unwrap() - } + pub fn raw_name(&self) -> BnString { + unsafe { BnString::from_raw(BNGetSymbolRawName(self.handle)) } } pub fn address(&self) -> u64 { |
