diff options
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r-- | src/node_buffer.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc index e810760790..ca2c6a89cb 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -591,6 +591,8 @@ void Fill(const FunctionCallbackInfo<Value>& args) { THROW_AND_RETURN_IF_OOB(start <= end); THROW_AND_RETURN_IF_OOB(fill_length + start <= ts_obj_length); + args.GetReturnValue().Set(static_cast<double>(fill_length)); + // First check if Buffer has been passed. if (Buffer::HasInstance(args[1])) { SPREAD_BUFFER_ARG(args[1], fill_obj); @@ -612,8 +614,10 @@ void Fill(const FunctionCallbackInfo<Value>& args) { enc == UTF8 ? str_obj->Utf8Length() : enc == UCS2 ? str_obj->Length() * sizeof(uint16_t) : str_obj->Length(); - if (str_length == 0) + if (str_length == 0) { + args.GetReturnValue().Set(0); return; + } // Can't use StringBytes::Write() in all cases. For example if attempting // to write a two byte character into a one byte Buffer. @@ -643,7 +647,7 @@ void Fill(const FunctionCallbackInfo<Value>& args) { // TODO(trevnorris): Should this throw? Because of the string length was // greater than 0 but couldn't be written then the string was invalid. if (str_length == 0) - return; + return args.GetReturnValue().Set(0); } start_fill: |