diff options
| author | Mason Reed <mason@vector35.com> | 2026-05-26 10:34:21 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2026-05-26 10:35:59 -0400 |
| commit | 736c59125c86343723957298351225f21dbb78b5 (patch) | |
| tree | 79a39bb1c350ec3a63f1cfd2fb86c0ab4d2b1051 /plugins | |
| parent | ea82d201e7efb2065d0cea459bea0fcda1985762 (diff) | |
[WARP] Fix crash when no default calling convention is registered
Fixes https://github.com/Vector35/binaryninja-api/issues/8181
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/warp/src/convert/types.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/warp/src/convert/types.rs b/plugins/warp/src/convert/types.rs index 6969ac67..93cae0fc 100644 --- a/plugins/warp/src/convert/types.rs +++ b/plugins/warp/src/convert/types.rs @@ -274,13 +274,13 @@ pub fn from_bn_calling_convention(raw_cc: BNRef<BNCallingConvention>) -> Calling pub fn to_bn_calling_convention<A: BNArchitecture>( arch: &A, calling_convention: &CallingConvention, -) -> BNRef<BNCallingConvention> { +) -> Option<BNRef<BNCallingConvention>> { for cc in &arch.calling_conventions() { if cc.name().as_str() == calling_convention.name { - return cc.clone(); + return Some(cc.clone()); } } - arch.get_default_calling_convention().unwrap() + None } // Always pass the architecture unless you know what you're doing! @@ -443,9 +443,11 @@ pub fn to_bn_type<A: BNArchitecture + Copy>(arch: Option<A>, ty: &Type) -> BNRef // TODO: Variable arguments let variable_args = false; // If we have a calling convention we run the extended function type creation. - match (c.calling_convention.as_ref(), arch.as_ref()) { - (Some(cc), Some(arch)) => { - let calling_convention = to_bn_calling_convention(arch, cc); + let default_cc = arch.and_then(|a| a.get_default_calling_convention()); + match (c.calling_convention.as_ref(), arch.as_ref(), default_cc) { + (Some(cc), Some(arch), Some(default_cc)) => { + let calling_convention = + to_bn_calling_convention(arch, cc).unwrap_or(default_cc); BNType::function_with_opts( &return_type, ¶ms, @@ -454,7 +456,7 @@ pub fn to_bn_type<A: BNArchitecture + Copy>(arch: Option<A>, ty: &Type) -> BNRef BNConf::new(0, 0), ) } - (_, _) => BNType::function(&return_type, params, variable_args), + (_, _, _) => BNType::function(&return_type, params, variable_args), } } TypeClass::Referrer(c) => { |
