Browse Source

buffer: fix not return on error

Throwing a JS error from C++ does not mean the function will return
early. This must be done manually.

Also remove extraneous comment no longer relevant.

Fix: 2903030 "buffer: switch API to return MaybeLocal<T>"
PR-URL: https://github.com/nodejs/io.js/pull/2225
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v4.0.0-rc
Trevor Norris 10 years ago
committed by Rod Vagg
parent
commit
e6ab2d92bc
  1. 3
      src/node_buffer.cc

3
src/node_buffer.cc

@ -287,7 +287,6 @@ MaybeLocal<Object> Copy(Isolate* isolate, const char* data, size_t length) {
} }
// Make a copy of "data". Why this isn't called "Copy", we'll never know.
MaybeLocal<Object> New(Environment* env, const char* data, size_t length) { MaybeLocal<Object> New(Environment* env, const char* data, size_t length) {
EscapableHandleScope scope(env->isolate()); EscapableHandleScope scope(env->isolate());
@ -474,7 +473,7 @@ void Slice(const FunctionCallbackInfo<Value>& args) {
Maybe<bool> mb = Maybe<bool> mb =
ui->SetPrototype(env->context(), env->buffer_prototype_object()); ui->SetPrototype(env->context(), env->buffer_prototype_object());
if (!mb.FromMaybe(false)) if (!mb.FromMaybe(false))
env->ThrowError("Unable to set Object prototype"); return env->ThrowError("Unable to set Object prototype");
args.GetReturnValue().Set(ui); args.GetReturnValue().Set(ui);
} }

Loading…
Cancel
Save