summaryrefslogtreecommitdiff
path: root/ext/ffi/lib.rs
diff options
context:
space:
mode:
authorAapo Alasuutari <aapo.alasuutari@gmail.com>2022-10-07 07:50:18 +0300
committerGitHub <noreply@github.com>2022-10-07 10:20:18 +0530
commit19e4e821d582b625797b8a17737dfa823a6aca21 (patch)
treed1860afebf98ab49002db6f133c17d3b8e85fc62 /ext/ffi/lib.rs
parent5733de8a2e1e9bd821733f530a33d9a6c1f5c460 (diff)
fix(ext/ffi): Fix usize and isize FFI callback parameters missing match arm (#16172)
Mea culpa. Back when I re-introduced parameter and return value types to FFI callbacks I failed to properly account for the change in match arm logic. As a result, usize and isize parameters in FFI callbacks currently enter the branch meant for void only. This PR changes the match arms to all be explicit, making sure that void is the only arm marked unreachable and that it stays that way.
Diffstat (limited to 'ext/ffi/lib.rs')
-rw-r--r--ext/ffi/lib.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs
index bc3a58209..1f7619f7e 100644
--- a/ext/ffi/lib.rs
+++ b/ext/ffi/lib.rs
@@ -1495,7 +1495,7 @@ unsafe fn do_ffi_callback(
let value = *((*val) as *const u32);
v8::Integer::new_from_unsigned(scope, value).into()
}
- NativeType::I64 => {
+ NativeType::I64 | NativeType::ISize => {
let result = *((*val) as *const i64);
if result > MAX_SAFE_INTEGER as i64 || result < MIN_SAFE_INTEGER as i64
{
@@ -1504,7 +1504,7 @@ unsafe fn do_ffi_callback(
v8::Number::new(scope, result as f64).into()
}
}
- NativeType::U64 => {
+ NativeType::U64 | NativeType::USize => {
let result = *((*val) as *const u64);
if result > MAX_SAFE_INTEGER as u64 {
v8::BigInt::new_from_u64(scope, result).into()
@@ -1520,9 +1520,7 @@ unsafe fn do_ffi_callback(
v8::Number::new(scope, result as f64).into()
}
}
- _ => {
- unreachable!()
- }
+ NativeType::Void => unreachable!(),
};
params.push(value);
}