Skip to content

Commit 4e9f18d

Browse files
committed
src: test and code review updates [squash]
1 parent afdabb7 commit 4e9f18d

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

deps/ncrypto/ncrypto.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "ncrypto.h"
22
#include <algorithm>
3+
#include <cstring>
34
#include "openssl/bn.h"
45
#if OPENSSL_VERSION_MAJOR >= 3
56
#include "openssl/provider.h"

src/crypto/crypto_util.cc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ bool CryptoErrorStore::Empty() const {
243243
return errors_.empty();
244244
}
245245

246-
v8::MaybeLocal<v8::Value> cryptoErrorListToException(
246+
MaybeLocal<Value> cryptoErrorListToException(
247247
Environment* env, const ncrypto::CryptoErrorList& errors) {
248248
// The CryptoErrorList contains a listing of zero or more errors.
249249
// If there are no errors, it is likely a bug but we will return
@@ -261,7 +261,7 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
261261
if (!String::NewFromUtf8(
262262
env->isolate(), last.data(), NewStringType::kNormal, last.size())
263263
.ToLocal(&message)) {
264-
return MaybeLocal<Value>();
264+
return {};
265265
}
266266

267267
Local<Value> exception = Exception::Error(message);
@@ -277,13 +277,9 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
277277
auto last = errors.end();
278278
last--;
279279
while (current != last) {
280-
Local<String> error;
281-
if (!String::NewFromUtf8(env->isolate(),
282-
current->data(),
283-
NewStringType::kNormal,
284-
current->size())
285-
.ToLocal(&error)) {
286-
return MaybeLocal<Value>();
280+
Local<Value> error;
281+
if (!ToV8Value(env->context(), *current).ToLocal(&error)) {
282+
return {};
287283
}
288284
stack.push_back(error);
289285
++current;
@@ -295,7 +291,7 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
295291
if (!exception_obj
296292
->Set(env->context(), env->openssl_error_stack(), stackArray)
297293
.IsNothing()) {
298-
return MaybeLocal<Value>();
294+
return {};
299295
}
300296
}
301297
return exception;

test/parallel/test-process-versions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const expected_keys = [
2424
'ada',
2525
'cjs_module_lexer',
2626
'nbytes',
27+
'ncrypto',
2728
];
2829

2930
const hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js');
@@ -64,6 +65,7 @@ assert.match(process.versions.llhttp, commonTemplate);
6465
assert.match(process.versions.node, commonTemplate);
6566
assert.match(process.versions.uv, commonTemplate);
6667
assert.match(process.versions.nbytes, commonTemplate);
68+
assert.match(process.versions.ncrypto, commonTemplate);
6769
assert.match(process.versions.zlib, /^\d+(?:\.\d+){1,3}(?:-.*)?$/);
6870

6971
if (hasUndici) {

0 commit comments

Comments
 (0)