diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 02a6a79492cf12..11a8abfb557fd2 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -327,13 +327,8 @@ MaybeLocal New(Isolate* isolate, CHECK(actual <= length); if (LIKELY(actual > 0)) { - if (actual < length) { - std::unique_ptr old_store = std::move(store); - store = ArrayBuffer::NewBackingStore(isolate, actual); - memcpy(static_cast(store->Data()), - static_cast(old_store->Data()), - actual); - } + if (actual < length) + store = BackingStore::Reallocate(isolate, std::move(store), actual); Local buf = ArrayBuffer::New(isolate, std::move(store)); Local obj; if (UNLIKELY(!New(isolate, buf, 0, actual).ToLocal(&obj)))