From b38415d7e9abad2a8255c6b527ab7a033851c5f2 Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Fri, 24 Jan 2025 12:27:08 -0800 Subject: [PATCH] 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 Reviewed-by: Filippo Valsorda LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov --- src/crypto/internal/boring/ecdh.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/crypto/internal/boring/ecdh.go b/src/crypto/internal/boring/ecdh.go index ff29eb17b1..4a887fdfd6 100644 --- a/src/crypto/internal/boring/ecdh.go +++ b/src/crypto/internal/boring/ecdh.go @@ -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 -- 2.51.0