@@ -3302,15 +3302,18 @@ Local<Function> KeyObject::Initialize(Environment* env, Local<Object> target) {
33023302 return function;
33033303}
33043304
3305- Local <Object> KeyObject::Create (Environment* env,
3306- KeyType key_type,
3307- const ManagedEVPPKey& pkey) {
3305+ MaybeLocal <Object> KeyObject::Create (Environment* env,
3306+ KeyType key_type,
3307+ const ManagedEVPPKey& pkey) {
33083308 CHECK_NE (key_type, kKeyTypeSecret );
33093309 Local<Value> type = Integer::New (env->isolate (), key_type);
3310- Local<Object> obj =
3311- env->crypto_key_object_constructor ()->NewInstance (env->context (),
3312- 1 , &type)
3313- .ToLocalChecked ();
3310+ Local<Object> obj;
3311+ if (!env->crypto_key_object_constructor ()
3312+ ->NewInstance (env->context (), 1 , &type)
3313+ .ToLocal (&obj)) {
3314+ return MaybeLocal<Object>();
3315+ }
3316+
33143317 KeyObject* key = Unwrap<KeyObject>(obj);
33153318 CHECK (key);
33163319 if (key_type == kKeyTypePublic )
@@ -5798,24 +5801,22 @@ class GenerateKeyPairJob : public CryptoJob {
57985801 if (public_key_encoding_.output_key_object_ ) {
57995802 // Note that this has the downside of containing sensitive data of the
58005803 // private key.
5801- *pubkey = KeyObject::Create (env, kKeyTypePublic , pkey_);
5804+ if (!KeyObject::Create (env, kKeyTypePublic , pkey_).ToLocal (pubkey))
5805+ return false ;
58025806 } else {
5803- MaybeLocal<Value> maybe_pubkey =
5804- WritePublicKey (env, pkey_.get (), public_key_encoding_);
5805- if (maybe_pubkey.IsEmpty ())
5807+ if (!WritePublicKey (env, pkey_.get (), public_key_encoding_)
5808+ .ToLocal (pubkey))
58065809 return false ;
5807- *pubkey = maybe_pubkey.ToLocalChecked ();
58085810 }
58095811
58105812 // Now do the same for the private key.
58115813 if (private_key_encoding_.output_key_object_ ) {
5812- *privkey = KeyObject::Create (env, kKeyTypePrivate , pkey_);
5814+ if (!KeyObject::Create (env, kKeyTypePrivate , pkey_).ToLocal (privkey))
5815+ return false ;
58135816 } else {
5814- MaybeLocal<Value> maybe_privkey =
5815- WritePrivateKey (env, pkey_.get (), private_key_encoding_);
5816- if (maybe_privkey.IsEmpty ())
5817+ if (!WritePrivateKey (env, pkey_.get (), private_key_encoding_)
5818+ .ToLocal (privkey))
58175819 return false ;
5818- *privkey = maybe_privkey.ToLocalChecked ();
58195820 }
58205821
58215822 return true ;
0 commit comments