GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: avoid using ToLocalChecked in crypto_hash · nodejs/node@d4d7172

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/crypto
    • crypto_hash.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_hash.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_hash.cc
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace node {
3030
using ncrypto::DataPointer;
3131
using ncrypto::EVPMDCtxPointer;
3232
using ncrypto::MarkPopErrorOnReturn;
33+
using v8::ArrayBuffer;
3334
using v8::Context;
3435
using v8::FunctionCallbackInfo;
3536
using v8::FunctionTemplate;
@@ -43,8 +44,11 @@ using v8::Maybe;
4344
using v8::MaybeLocal;
4445
using v8::Name;
4546
using v8::Nothing;
47+
using v8::Null;
4648
using v8::Object;
49+
using v8::String;
4750
using v8::Uint32;
51+
using v8::Uint8Array;
4852
using v8::Value;
4953

5054
namespace crypto {
@@ -195,12 +199,12 @@ void Hash::GetCachedAliases(const FunctionCallbackInfo<Value>& args) {
195199
values.reserve(size);
196200
for (auto& [alias, id] : env->alias_to_md_id_map) {
197201
names.push_back(OneByteString(isolate, alias));
198-
values.push_back(v8::Uint32::New(isolate, id));
202+
values.push_back(Uint32::New(isolate, id));
199203
}
200204
#else
201205
CHECK(env->alias_to_md_id_map.empty());
202206
#endif
203-
Local<Value> prototype = v8::Null(isolate);
207+
Local<Value> prototype = Null(isolate);
204208
Local<Object> result =
205209
Object::New(isolate, prototype, names.data(), values.data(), size);
206210
args.GetReturnValue().Set(result);
@@ -233,7 +237,7 @@ const EVP_MD* GetDigestImplementation(Environment* env,
233237
if (algorithm_cache.As<Object>()
234238
->Set(isolate->GetCurrentContext(),
235239
algorithm,
236-
v8::Int32::New(isolate, result.cache_id))
240+
Int32::New(isolate, result.cache_id))
237241
.IsNothing()) {
238242
return nullptr;
239243
}
@@ -311,11 +315,13 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
311315

312316
if (output_length == 0) {
313317
if (output_enc == BUFFER) {
314-
Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 0);
315-
args.GetReturnValue().Set(
316-
Buffer::New(isolate, ab, 0, 0).ToLocalChecked());
318+
Local<Uint8Array> u8;
319+
if (Buffer::New(isolate, ArrayBuffer::New(isolate, 0), 0, 0)
320+
.ToLocal(&u8)) {
321+
args.GetReturnValue().Set(u8);
322+
}
317323
} else {
318-
args.GetReturnValue().Set(v8::String::Empty(isolate));
324+
args.GetReturnValue().Set(String::Empty(isolate));
319325
}
320326
return;
321327
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.