diff options
author | Anna Henningsen <anna@addaleax.net> | 2016-12-06 02:19:57 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2016-12-12 16:58:40 +0100 |
commit | 9ee915be76f9e4cc8bc43020a721a03257f9b984 (patch) | |
tree | f56973f121eb0644b8f0310c0dcd812e5d9491ba /src/node_buffer.cc | |
parent | f418a227677a2801eaa1ceb084d64bd16e17fc45 (diff) | |
download | android-node-v8-9ee915be76f9e4cc8bc43020a721a03257f9b984.tar.gz android-node-v8-9ee915be76f9e4cc8bc43020a721a03257f9b984.tar.bz2 android-node-v8-9ee915be76f9e4cc8bc43020a721a03257f9b984.zip |
buffer: handle UCS2 `.fill()` properly on BE
There was a byte-order mismatch for `buffer#fill` on big-endian
platforms. Weirdly, the tests seemed to expect that wrong behaviour.
PR-URL: https://github.com/nodejs/node/pull/9837
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r-- | src/node_buffer.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 540de1827f..0e96fd6dee 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -606,6 +606,9 @@ void Fill(const FunctionCallbackInfo<Value>& args) { } else if (enc == UCS2) { node::TwoByteValue str(env->isolate(), args[1]); + if (IsBigEndian()) + SwapBytes16(reinterpret_cast<char*>(&str[0]), str_length); + memcpy(ts_obj_data + start, *str, MIN(str_length, fill_length)); } else { |