mirror of https://github.com/golang/go.git
crypto/internal/boring: remove unnecessary struct field
That could result in a hanging pointer. Change-Id: I547950a3d3010e03b75f70f5f021f20124e2cef0 Reviewed-on: https://go-review.googlesource.com/c/go/+/644120 Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
586e205522
commit
b38415d7e9
|
|
@ -17,7 +17,6 @@ import (
|
|||
type PublicKeyECDH struct {
|
||||
curve string
|
||||
key *C.GO_EC_POINT
|
||||
group *C.GO_EC_GROUP
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +58,7 @@ func NewPublicKeyECDH(curve string, bytes []byte) (*PublicKeyECDH, error) {
|
|||
return nil, errors.New("point not on curve")
|
||||
}
|
||||
|
||||
k := &PublicKeyECDH{curve, key, group, append([]byte(nil), bytes...)}
|
||||
k := &PublicKeyECDH{curve, key, append([]byte(nil), bytes...)}
|
||||
// Note: Because of the finalizer, any time k.key is passed to cgo,
|
||||
// that call must be followed by a call to runtime.KeepAlive(k),
|
||||
// to make sure k is not collected (and finalized) before the cgo
|
||||
|
|
@ -122,7 +121,7 @@ func (k *PrivateKeyECDH) PublicKey() (*PublicKeyECDH, error) {
|
|||
C._goboringcrypto_EC_POINT_free(pt)
|
||||
return nil, err
|
||||
}
|
||||
pub := &PublicKeyECDH{k.curve, pt, group, bytes}
|
||||
pub := &PublicKeyECDH{k.curve, pt, bytes}
|
||||
// Note: Same as in NewPublicKeyECDH regarding finalizer and KeepAlive.
|
||||
runtime.SetFinalizer(pub, (*PublicKeyECDH).finalize)
|
||||
return pub, nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue