diff --git a/src/node_buffer.cc b/src/node_buffer.cc index b2fa0ef20174a9..28ded0e3010116 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -424,12 +424,13 @@ MaybeLocal New(Environment* env, True(env->isolate())).IsNothing()) { return Local(); } - MaybeLocal ui = Buffer::New(env, ab, 0, length); + MaybeLocal maybe_ui = Buffer::New(env, ab, 0, length); - if (ui.IsEmpty()) + Local ui; + if (!maybe_ui.ToLocal(&ui)) return MaybeLocal(); - return scope.Escape(ui.ToLocalChecked()); + return scope.Escape(ui); } // Warning: This function needs `data` to be allocated with malloc() and not