Skip to content

Commit 286d265

Browse files
committed
Fix double free in CoreCallingConvention::callee_saved_registers
Also added an assertion in the types unit test to catch it Fixes #6379
1 parent d4aabea commit 286d265

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

rust/src/calling_convention.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ impl CallingConvention for CoreCallingConvention {
574574
unsafe {
575575
let mut count = 0;
576576
let regs_ptr = BNGetCalleeSavedRegisters(self.handle, &mut count);
577-
BNFreeRegisterList(regs_ptr);
578577
let regs: Vec<RegisterId> = std::slice::from_raw_parts(regs_ptr, count)
579578
.iter()
580579
.copied()

rust/tests/types.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
use binaryninja::confidence::Conf;
12
use binaryninja::headless::Session;
3+
use binaryninja::platform::Platform;
24
use binaryninja::types::{MemberAccess, MemberScope, StructureBuilder, StructureMember, Type};
35
use rstest::*;
46

@@ -12,6 +14,14 @@ fn session() -> Session {
1214
fn test_type_to_string(_session: &Session) {
1315
let test_type = Type::int(4, true);
1416
assert_eq!(test_type.to_string(), "int32_t".to_string());
17+
18+
let platform = Platform::by_name("x86").expect("Failed to get platform");
19+
let calling_conv = platform
20+
.get_default_calling_convention()
21+
.expect("Failed to get calling convention");
22+
let test_fn_type =
23+
Type::function_with_opts(&test_type, &[], false, calling_conv, Conf::new(0, 0));
24+
assert_eq!(test_fn_type.to_string(), "int32_t()");
1525
}
1626

1727
#[rstest]

0 commit comments

Comments
 (0)