From a6242772ec57db848a92f51df162efcddb826a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 11 Nov 2022 12:07:23 +0100 Subject: [PATCH] src: fix ArrayBuffer::Detach deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/45579 Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- src/js_native_api_v8.cc | 2 +- src/node_blob.cc | 4 +++- src/node_buffer.cc | 6 +++--- src/node_messaging.cc | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index abc9e56d6b0bbb..bf38108c6b0fab 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -3239,7 +3239,7 @@ napi_status NAPI_CDECL napi_detach_arraybuffer(napi_env env, RETURN_STATUS_IF_FALSE( env, it->IsDetachable(), napi_detachable_arraybuffer_expected); - it->Detach(); + it->Detach(v8::Local()).Check(); return napi_clear_last_error(env); } diff --git a/src/node_blob.cc b/src/node_blob.cc index 61960fee14b6c6..8a4373b06ba7be 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -107,7 +107,9 @@ void Blob::New(const FunctionCallbackInfo& args) { CHECK_EQ(view->ByteOffset(), 0); std::shared_ptr store = view->Buffer()->GetBackingStore(); size_t byte_length = view->ByteLength(); - view->Buffer()->Detach(); // The Blob will own the backing store now. + view->Buffer() + ->Detach(Local()) + .Check(); // The Blob will own the backing store now. entries.emplace_back(BlobEntry{std::move(store), byte_length, 0}); len += byte_length; } else { diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 3a9aeb99a89240..bd09e600367378 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -125,7 +125,7 @@ Local CallbackInfo::CreateTrackedArrayBuffer( // V8 simply ignores the BackingStore deleter callback if data == nullptr, // but our API contract requires it being called. if (data == nullptr) { - ab->Detach(); + ab->Detach(Local()).Check(); self->OnBackingStoreFree(); // This calls `callback` asynchronously. } else { // Store the ArrayBuffer so that we can detach it later. @@ -156,7 +156,7 @@ void CallbackInfo::CleanupHook(void* data) { HandleScope handle_scope(self->env_->isolate()); Local ab = self->persistent_.Get(self->env_->isolate()); if (!ab.IsEmpty() && ab->IsDetachable()) { - ab->Detach(); + ab->Detach(Local()).Check(); self->persistent_.Reset(); } } @@ -1256,7 +1256,7 @@ void DetachArrayBuffer(const FunctionCallbackInfo& args) { Local buf = args[0].As(); if (buf->IsDetachable()) { std::shared_ptr store = buf->GetBackingStore(); - buf->Detach(); + buf->Detach(Local()).Check(); args.GetReturnValue().Set(ArrayBuffer::New(env->isolate(), store)); } } diff --git a/src/node_messaging.cc b/src/node_messaging.cc index f88270fc75de91..5c163d587ba196 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -516,7 +516,7 @@ Maybe Message::Serialize(Environment* env, for (Local ab : array_buffers) { // If serialization succeeded, we render it inaccessible in this Isolate. std::shared_ptr backing_store = ab->GetBackingStore(); - ab->Detach(); + ab->Detach(Local()).Check(); array_buffers_.emplace_back(std::move(backing_store)); }