Skip to content

Commit

Permalink
src: make failure of closing scopes fatal
Browse files Browse the repository at this point in the history
Properly handle failures instead of ignoring them.

PR-URL: nodejs/node-addon-api#566
Reviewed-By: NickNaso <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
  • Loading branch information
kevindavies8 committed Oct 23, 2019
1 parent 3c89a94 commit 74bdc4e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3468,7 +3468,10 @@ inline HandleScope::HandleScope(Napi::Env env) : _env(env) {
}

inline HandleScope::~HandleScope() {
napi_close_handle_scope(_env, _scope);
napi_status status = napi_close_handle_scope(_env, _scope);
NAPI_FATAL_IF_FAILED(status,
"HandleScope::~HandleScope",
"napi_close_handle_scope");
}

inline HandleScope::operator napi_handle_scope() const {
Expand All @@ -3493,7 +3496,10 @@ inline EscapableHandleScope::EscapableHandleScope(Napi::Env env) : _env(env) {
}

inline EscapableHandleScope::~EscapableHandleScope() {
napi_close_escapable_handle_scope(_env, _scope);
napi_status status = napi_close_escapable_handle_scope(_env, _scope);
NAPI_FATAL_IF_FAILED(status,
"EscapableHandleScope::~EscapableHandleScope",
"napi_close_escapable_handle_scope");
}

inline EscapableHandleScope::operator napi_escapable_handle_scope() const {
Expand Down Expand Up @@ -3529,7 +3535,10 @@ inline CallbackScope::CallbackScope(napi_env env, napi_async_context context)
}

inline CallbackScope::~CallbackScope() {
napi_close_callback_scope(_env, _scope);
napi_status status = napi_close_callback_scope(_env, _scope);
NAPI_FATAL_IF_FAILED(status,
"CallbackScope::~CallbackScope",
"napi_close_callback_scope");
}

inline CallbackScope::operator napi_callback_scope() const {
Expand Down

0 comments on commit 74bdc4e

Please sign in to comment.