diff options
author | Trevor Norris <trev.norris@gmail.com> | 2015-06-02 20:09:03 +0300 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-08-04 21:56:11 +0300 |
commit | 36f78f4c1cbe0c0dd2a83f6b1dba534a9d722a49 (patch) | |
tree | 3709d5c5f0e3697e06c7f9ba3b56af51256aba84 /src/js_stream.cc | |
parent | 571ec13841699d255025b8eaeab17c84fdb4add3 (diff) |
buffer: switch API to return MaybeLocal<T>
Instead of aborting in case of internal failure, return an empty
Local<Object>. Using the MaybeLocal<T> API, users must check their
return values.
PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/js_stream.cc')
-rw-r--r-- | src/js_stream.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/js_stream.cc b/src/js_stream.cc index 91041d02011..aa8de3a9ad9 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -88,8 +88,11 @@ int JSStream::DoWrite(WriteWrap* w, HandleScope scope(env()->isolate()); Local<Array> bufs_arr = Array::New(env()->isolate(), count); - for (size_t i = 0; i < count; i++) - bufs_arr->Set(i, Buffer::New(env(), bufs[i].base, bufs[i].len)); + Local<Object> buf; + for (size_t i = 0; i < count; i++) { + buf = Buffer::New(env(), bufs[i].base, bufs[i].len).ToLocalChecked(); + bufs_arr->Set(i, buf); + } Local<Value> argv[] = { w->object(), @@ -134,11 +137,13 @@ void JSStream::DoAlloc(const FunctionCallbackInfo<Value>& args) { uv_buf_t buf; wrap->OnAlloc(args[0]->Int32Value(), &buf); - args.GetReturnValue().Set(Buffer::New(wrap->env(), - buf.base, - buf.len, - FreeCallback, - nullptr)); + Local<Object> vbuf = Buffer::New( + wrap->env(), + buf.base, + buf.len, + FreeCallback, + nullptr).ToLocalChecked(); + return args.GetReturnValue().Set(vbuf); } |