Skip to content

Commit

Permalink
n-api: tighten null-checking and clean up last error
Browse files Browse the repository at this point in the history
We left out null-checks for many of the parameters passed to our APIs.
In particular, arguments of type `napi_value` were often accepted
without a null-check, even though they should never be null.

Additionally, many APIs simply returned `napi_ok` on success. This
leaves in place an error that may have occurred in a previous N-API
call. Others (those which perform `NAPI_PREAMBLE(env)` at the top)
OTOH explicitly clear the last error before proceeding. With this
modification all APIs explicitly clear the last error on success.

Fixes: nodejs/abi-stable-node#227
PR-URL: nodejs#12539
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
Gabriel Schulhof committed Apr 10, 2018
1 parent 7a093c2 commit 89e85e7
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 48 deletions.
Loading

0 comments on commit 89e85e7

Please sign in to comment.