summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-01-31 21:56:21 -0500
committerMason Reed <mason@vector35.com>2025-01-31 21:56:48 -0500
commit286d265497a840f06e4ccb321c9bc81139d2e9a2 (patch)
tree666b9d58606543eb6b6ee1346e55784ca4284f79 /rust
parentd4aabea6e7f32690e39140062f1829a180d7f698 (diff)
Fix double free in CoreCallingConvention::callee_saved_registers
Also added an assertion in the types unit test to catch it Fixes #6379
Diffstat (limited to 'rust')
-rw-r--r--rust/src/calling_convention.rs1
-rw-r--r--rust/tests/types.rs10
2 files changed, 10 insertions, 1 deletions
diff --git a/rust/src/calling_convention.rs b/rust/src/calling_convention.rs
index 929cc26b..9c1493e1 100644
--- a/rust/src/calling_convention.rs
+++ b/rust/src/calling_convention.rs
@@ -574,7 +574,6 @@ impl CallingConvention for CoreCallingConvention {
unsafe {
let mut count = 0;
let regs_ptr = BNGetCalleeSavedRegisters(self.handle, &mut count);
- BNFreeRegisterList(regs_ptr);
let regs: Vec<RegisterId> = std::slice::from_raw_parts(regs_ptr, count)
.iter()
.copied()
diff --git a/rust/tests/types.rs b/rust/tests/types.rs
index f745de0c..98530dc6 100644
--- a/rust/tests/types.rs
+++ b/rust/tests/types.rs
@@ -1,4 +1,6 @@
+use binaryninja::confidence::Conf;
use binaryninja::headless::Session;
+use binaryninja::platform::Platform;
use binaryninja::types::{MemberAccess, MemberScope, StructureBuilder, StructureMember, Type};
use rstest::*;
@@ -12,6 +14,14 @@ fn session() -> Session {
fn test_type_to_string(_session: &Session) {
let test_type = Type::int(4, true);
assert_eq!(test_type.to_string(), "int32_t".to_string());
+
+ let platform = Platform::by_name("x86").expect("Failed to get platform");
+ let calling_conv = platform
+ .get_default_calling_convention()
+ .expect("Failed to get calling convention");
+ let test_fn_type =
+ Type::function_with_opts(&test_type, &[], false, calling_conv, Conf::new(0, 0));
+ assert_eq!(test_fn_type.to_string(), "int32_t()");
}
#[rstest]