@@ -3329,15 +3329,18 @@ Local<Function> KeyObject::Initialize(Environment* env, Local<Object> target) {
3329
3329
return function;
3330
3330
}
3331
3331
3332
- Local <Object> KeyObject::Create (Environment* env,
3333
- KeyType key_type,
3334
- const ManagedEVPPKey& pkey) {
3332
+ MaybeLocal <Object> KeyObject::Create (Environment* env,
3333
+ KeyType key_type,
3334
+ const ManagedEVPPKey& pkey) {
3335
3335
CHECK_NE (key_type, kKeyTypeSecret );
3336
3336
Local<Value> type = Integer::New (env->isolate (), key_type);
3337
- Local<Object> obj =
3338
- env->crypto_key_object_constructor ()->NewInstance (env->context (),
3339
- 1 , &type)
3340
- .ToLocalChecked ();
3337
+ Local<Object> obj;
3338
+ if (!env->crypto_key_object_constructor ()
3339
+ ->NewInstance (env->context (), 1 , &type)
3340
+ .ToLocal (&obj)) {
3341
+ return MaybeLocal<Object>();
3342
+ }
3343
+
3341
3344
KeyObject* key = Unwrap<KeyObject>(obj);
3342
3345
CHECK (key);
3343
3346
if (key_type == kKeyTypePublic )
@@ -5825,24 +5828,22 @@ class GenerateKeyPairJob : public CryptoJob {
5825
5828
if (public_key_encoding_.output_key_object_ ) {
5826
5829
// Note that this has the downside of containing sensitive data of the
5827
5830
// private key.
5828
- *pubkey = KeyObject::Create (env, kKeyTypePublic , pkey_);
5831
+ if (!KeyObject::Create (env, kKeyTypePublic , pkey_).ToLocal (pubkey))
5832
+ return false ;
5829
5833
} else {
5830
- MaybeLocal<Value> maybe_pubkey =
5831
- WritePublicKey (env, pkey_.get (), public_key_encoding_);
5832
- if (maybe_pubkey.IsEmpty ())
5834
+ if (!WritePublicKey (env, pkey_.get (), public_key_encoding_)
5835
+ .ToLocal (pubkey))
5833
5836
return false ;
5834
- *pubkey = maybe_pubkey.ToLocalChecked ();
5835
5837
}
5836
5838
5837
5839
// Now do the same for the private key.
5838
5840
if (private_key_encoding_.output_key_object_ ) {
5839
- *privkey = KeyObject::Create (env, kKeyTypePrivate , pkey_);
5841
+ if (!KeyObject::Create (env, kKeyTypePrivate , pkey_).ToLocal (privkey))
5842
+ return false ;
5840
5843
} else {
5841
- MaybeLocal<Value> maybe_privkey =
5842
- WritePrivateKey (env, pkey_.get (), private_key_encoding_);
5843
- if (maybe_privkey.IsEmpty ())
5844
+ if (!WritePrivateKey (env, pkey_.get (), private_key_encoding_)
5845
+ .ToLocal (privkey))
5844
5846
return false ;
5845
- *privkey = maybe_privkey.ToLocalChecked ();
5846
5847
}
5847
5848
5848
5849
return true ;
0 commit comments