ffi: remove dead null check in callback arguments · nodejs/node@0002f0a · GitHub
Skip to content

Commit 0002f0a

Browse files
trivikraduh95
authored andcommitted
ffi: remove dead null check in callback arguments
InvokeCallback tested `args[i] == nullptr` and mapped the argument to JS `null`. `args` is libffi's avalue array, and libffi always points each slot at its own storage for the corresponding argument, so the slot pointers are never null and the branch never ran. The check also read as a guarantee the code does not provide: a NULL pointer argument surfaces as the BigInt `0n`, because ToJSArgument converts `ffi_type_pointer` values with BigInt::NewFromUnsigned. Drop the branch rather than reimplementing it in ToJSArgument, which would change behavior by making pointer parameters arrive as either a BigInt or `null`. Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Assisted-by: claude:opus-5 PR-URL: #64998 Reviewed-By: Paolo Insogna <paolo@cowtech.it>
1 parent 9024ec2 commit 0002f0a

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/node_ffi.cc

Lines changed: 4 additions & 7 deletions

0 commit comments

Comments
 (0)