summaryrefslogtreecommitdiff
path: root/rust/src/debuginfo.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-10 16:39:26 -0400
committerMason Reed <mason@vector35.com>2025-04-10 17:19:34 -0400
commit1973b852a1ffc2ea3e050d078a6f2b9933c199a1 (patch)
tree3f5fb2c328dd65ea2dff7b80de1b3e89d87d301e /rust/src/debuginfo.rs
parent2c79a0458cd5bc7af0264d18d8ca2fc1a7894228 (diff)
Fix function type construction leaking in Rust API
Diffstat (limited to 'rust/src/debuginfo.rs')
-rw-r--r--rust/src/debuginfo.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/rust/src/debuginfo.rs b/rust/src/debuginfo.rs
index 34daeac1..1353f8b1 100644
--- a/rust/src/debuginfo.rs
+++ b/rust/src/debuginfo.rs
@@ -770,16 +770,25 @@ impl DebugInfo {
}
/// Adds a function scoped under the current parser's name to the debug info
- pub fn add_function(&self, new_func: DebugFunctionInfo) -> bool {
- let short_name_bytes = new_func.short_name.map(|name| name.into_bytes_with_nul());
+ pub fn add_function(&self, new_func: &DebugFunctionInfo) -> bool {
+ let short_name_bytes = new_func
+ .short_name
+ .as_ref()
+ .map(|name| name.into_bytes_with_nul());
let short_name = short_name_bytes
.as_ref()
.map_or(std::ptr::null_mut() as *mut _, |name| name.as_ptr() as _);
- let full_name_bytes = new_func.full_name.map(|name| name.into_bytes_with_nul());
+ let full_name_bytes = new_func
+ .full_name
+ .as_ref()
+ .map(|name| name.into_bytes_with_nul());
let full_name = full_name_bytes
.as_ref()
.map_or(std::ptr::null_mut() as *mut _, |name| name.as_ptr() as _);
- let raw_name_bytes = new_func.raw_name.map(|name| name.into_bytes_with_nul());
+ let raw_name_bytes = new_func
+ .raw_name
+ .as_ref()
+ .map(|name| name.into_bytes_with_nul());
let raw_name = raw_name_bytes
.as_ref()
.map_or(std::ptr::null_mut() as *mut _, |name| name.as_ptr() as _);
@@ -816,11 +825,11 @@ impl DebugInfo {
fullName: full_name,
rawName: raw_name,
address: new_func.address,
- type_: match new_func.type_ {
+ type_: match &new_func.type_ {
Some(type_) => type_.handle,
_ => std::ptr::null_mut(),
},
- platform: match new_func.platform {
+ platform: match &new_func.platform {
Some(platform) => platform.handle,
_ => std::ptr::null_mut(),
},