Skip to content

Commit b8cb3da

Browse files
committed
fix LookupOrCreateArrayBuffer to make arraybuffers only the size required. Will we have a problem with length of zero?
1 parent a7f62a4 commit b8cb3da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/binding.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ class InstanceData final : public RefNapi::Instance {
141141
ab = it->second.ab.Value();
142142

143143
if (ab.IsEmpty()) {
144-
length = std::max<size_t>(length, kMaxLength);
144+
// this ALWAYS creates an arraybuffer of 1Gbyte?
145+
//length = std::max<size_t>(length, kMaxLength);
146+
length = std::min<size_t>(length, kMaxLength);
145147
ab = Buffer<char>::New(env, ptr, length, [this](Env env, char* ptr) {
146148
UnregisterArrayBuffer(ptr);
147149
}).ArrayBuffer();

0 commit comments

Comments
 (0)