diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-01-21 07:51:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-21 21:21:14 +0530 |
commit | 59289255411b902588619fd7d2f6e3e48af11d82 (patch) | |
tree | a328e565abb1695e57c99538d6482f62e5008cad /ext/ffi/dlfcn.rs | |
parent | 638b6ef554676422c43cc5c0ae2285ba369740bf (diff) |
fix(ext/ffi): disallow empty ffi structs (#17487)
This patch makes `NativeType` to `libffi::middle::Type` conversion
failliable and w.t disallows struct with empty fields. libffi does not
handle "empty" struct because they don't exist in C (or Rust).
Fixes #17481
Diffstat (limited to 'ext/ffi/dlfcn.rs')
-rw-r--r-- | ext/ffi/dlfcn.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/ffi/dlfcn.rs b/ext/ffi/dlfcn.rs index eeff2c8a7..a6b870c30 100644 --- a/ext/ffi/dlfcn.rs +++ b/ext/ffi/dlfcn.rs @@ -166,8 +166,9 @@ where .parameters .clone() .into_iter() - .map(libffi::middle::Type::from), - foreign_fn.result.clone().into(), + .map(libffi::middle::Type::try_from) + .collect::<Result<Vec<_>, _>>()?, + foreign_fn.result.clone().try_into()?, ); let func_key = v8::String::new(scope, &symbol_key).unwrap(); |