diff options
author | Trevor Norris <trev.norris@gmail.com> | 2015-06-17 11:34:12 -0600 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-08-04 11:56:12 -0700 |
commit | b625ab4242f55b7769e990ea1386d77ee224f273 (patch) | |
tree | 0c3a130eec1366e0186a5bbbc650d56ee1d6871b /src/node_buffer.cc | |
parent | 423d8944ce58bc8c3f90d2827339a4dea10ab96e (diff) | |
download | android-node-v8-b625ab4242f55b7769e990ea1386d77ee224f273.tar.gz android-node-v8-b625ab4242f55b7769e990ea1386d77ee224f273.tar.bz2 android-node-v8-b625ab4242f55b7769e990ea1386d77ee224f273.zip |
buffer: fix usage of kMaxLength
Starting in V8 v4.3 the maximum array index of a typed array is the same
as the largest Smi supported on a given architecture. To compensate for
these differences export kMaxLength from the buffer module with the
correct size for the given architecture.
PR-URL: https://github.com/nodejs/io.js/pull/2003
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r-- | src/node_buffer.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc index f567ef9373..96cd61f89e 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -71,6 +71,7 @@ using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Handle; using v8::HandleScope; +using v8::Integer; using v8::Isolate; using v8::Local; using v8::Maybe; @@ -1188,6 +1189,16 @@ void Initialize(Handle<Object> target, env->SetMethod(target, "writeDoubleLE", WriteDoubleLE); env->SetMethod(target, "writeFloatBE", WriteFloatBE); env->SetMethod(target, "writeFloatLE", WriteFloatLE); + + uint32_t kMaxLength; + if (sizeof(int32_t) == sizeof(intptr_t) || using_old_buffer) { + kMaxLength = 0x3fffffff; + } else { + kMaxLength = 0x7fffffff; + } + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "kMaxLength"), + Integer::NewFromUnsigned(env->isolate(), kMaxLength)).FromJust(); } |