Skip to content

Commit 3d4612d

Browse files
committed
don't allocate a text oid wice
Change-Id: Ifc1bc16df2d620c84e4321209456b1168bf11470
1 parent 64910a9 commit 3d4612d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/crypto/x509/oid.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type OID struct {
2727
// ParseOID parses a Object Identifier string, represented by ASCII numbers separated by dots.
2828
func ParseOID(oid string) (OID, error) {
2929
var o OID
30-
return o, o.UnmarshalText([]byte(oid))
30+
return o, o.unmarshalOIDText(oid)
3131
}
3232

3333
func newOIDFromDER(der []byte) (OID, bool) {
@@ -119,8 +119,10 @@ func (o OID) MarshalText() ([]byte, error) {
119119

120120
// UnmarshalText implements [encoding.TextUnmarshaler]
121121
func (o *OID) UnmarshalText(text []byte) error {
122-
oid := string(text)
122+
return o.unmarshalOIDText(string(text))
123+
}
123124

125+
func (o *OID) unmarshalOIDText(oid string) error {
124126
// (*big.Int).SetString allows +/- signs, but we don't want
125127
// to allow them in the string representation of Object Identifier, so
126128
// reject such encodings.

0 commit comments

Comments
 (0)