From c4e0e3947522901c32acdfba3958362fa5caed0f Mon Sep 17 00:00:00 2001 From: Sun Yimin Date: Thu, 15 Jun 2023 11:23:06 +0800 Subject: [PATCH] sm9: fix npe issue --- sm9/sm9_key.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sm9/sm9_key.go b/sm9/sm9_key.go index 952cecd..1d8b7db 100644 --- a/sm9/sm9_key.go +++ b/sm9/sm9_key.go @@ -264,7 +264,7 @@ func (priv *SignPrivateKey) MasterPublic() *SignMasterPublicKey { // SetMasterPublicKey bind the sign master public key to it. func (priv *SignPrivateKey) SetMasterPublicKey(pub *SignMasterPublicKey) { - if priv.SignMasterPublicKey.MasterPublicKey == nil { + if priv.SignMasterPublicKey == nil || priv.SignMasterPublicKey.MasterPublicKey == nil { priv.SignMasterPublicKey = pub } } @@ -538,7 +538,7 @@ func (priv *EncryptPrivateKey) MasterPublic() *EncryptMasterPublicKey { // SetMasterPublicKey bind the encrypt master public key to it. func (priv *EncryptPrivateKey) SetMasterPublicKey(pub *EncryptMasterPublicKey) { - if priv.EncryptMasterPublicKey.MasterPublicKey == nil { + if priv.EncryptMasterPublicKey == nil || priv.EncryptMasterPublicKey.MasterPublicKey == nil { priv.EncryptMasterPublicKey = pub } }