diff options
author | Trevor Norris <trev.norris@gmail.com> | 2015-06-02 11:09:03 -0600 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-08-04 11:56:11 -0700 |
commit | 36f78f4c1cbe0c0dd2a83f6b1dba534a9d722a49 (patch) | |
tree | 3709d5c5f0e3697e06c7f9ba3b56af51256aba84 /src/string_bytes.cc | |
parent | 571ec13841699d255025b8eaeab17c84fdb4add3 (diff) | |
download | android-node-v8-36f78f4c1cbe0c0dd2a83f6b1dba534a9d722a49.tar.gz android-node-v8-36f78f4c1cbe0c0dd2a83f6b1dba534a9d722a49.tar.bz2 android-node-v8-36f78f4c1cbe0c0dd2a83f6b1dba534a9d722a49.zip |
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/string_bytes.cc')
-rw-r--r-- | src/string_bytes.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 0bdb8aad91..36525a73ac 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -19,6 +19,7 @@ using v8::Handle; using v8::HandleScope; using v8::Isolate; using v8::Local; +using v8::Object; using v8::String; using v8::Value; @@ -702,7 +703,10 @@ Local<Value> StringBytes::Encode(Isolate* isolate, Local<String> val; switch (encoding) { case BUFFER: - return scope.Escape(Buffer::New(isolate, buf, buflen)); + { + Local<Object> vbuf = Buffer::New(isolate, buf, buflen).ToLocalChecked(); + return scope.Escape(vbuf); + } case ASCII: if (contains_non_ascii(buf, buflen)) { |