GeezerVison is showing github.com — ffi: remove dead null check in callback arguments · nodejs/node@0002f0a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_ffi.cc +4-7Lines changed: 4 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,7 +32,6 @@ using v8::Local; |
32 | 32 | using v8::LocalVector; |
33 | 33 | using v8::Maybe; |
34 | 34 | using v8::MaybeLocal; |
35 | | -using v8::Null; |
36 | 35 | using v8::Object; |
37 | 36 | using v8::PropertyAttribute; |
38 | 37 | using v8::ReadOnly; |
@@ -715,13 +714,11 @@ void DynamicLibrary::InvokeCallback(ffi_cif* cif, |
715 | 714 | size_t expected_args = cb->args.size(); |
716 | 715 | LocalVector<Value> callback_args(isolate, expected_args); |
717 | 716 |
|
| 717 | + // libffi always points `args[i]` at its own storage for the value of |
| 718 | + // argument `i`, so the slot pointers themselves are never null. A NULL |
| 719 | + // pointer argument surfaces as the BigInt `0n` via ToJSArgument. |
718 | 720 | for (size_t i = 0; i < expected_args; i++) { |
719 | | - if (args[i] == nullptr) { |
720 | | - callback_args[i] = Null(isolate); |
721 | | - continue; |
722 | | - } else { |
723 | | - callback_args[i] = ToJSArgument(isolate, cb->args[i], args[i]); |
724 | | - } |
| 721 | + callback_args[i] = ToJSArgument(isolate, cb->args[i], args[i]); |
725 | 722 | } |
726 | 723 |
|
727 | 724 | TryCatch try_catch(isolate); |
|