Skip to content

Commit

Permalink
src: use MaybeLocal.ToLocal instead of IsEmpty
Browse files Browse the repository at this point in the history
PR-URL: #35716
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
danbev authored and targos committed Nov 3, 2020
1 parent 01d7c46 commit 4b8b5fe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,13 @@ MaybeLocal<Object> New(Environment* env,
True(env->isolate())).IsNothing()) {
return Local<Object>();
}
MaybeLocal<Uint8Array> ui = Buffer::New(env, ab, 0, length);
MaybeLocal<Uint8Array> maybe_ui = Buffer::New(env, ab, 0, length);

if (ui.IsEmpty())
Local<Uint8Array> ui;
if (!maybe_ui.ToLocal(&ui))
return MaybeLocal<Object>();

return scope.Escape(ui.ToLocalChecked());
return scope.Escape(ui);
}

// Warning: This function needs `data` to be allocated with malloc() and not
Expand Down

0 comments on commit 4b8b5fe

Please sign in to comment.