sm9: fix npe issue

This commit is contained in:
Sun Yimin 2023-06-15 11:23:06 +08:00 committed by GitHub
parent a1b44f1a64
commit c4e0e39475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}
}