Procházet zdrojové kódy

Note that Buffer.Unmarshal does NOT reset the destination protobuf.

When repeatedly Unmarshalling into the same destination, this can cause a memory leak.
PiperOrigin-RevId: 135304939
notcarl před 9 roky
rodič
revize
1976b9edad
1 změnil soubory, kde provedl 2 přidání a 0 odebrání
  1. 2 0
      proto/decode.go

+ 2 - 0
proto/decode.go

@@ -340,6 +340,8 @@ func (p *Buffer) DecodeGroup(pb Message) error {
 // Buffer and places the decoded result in pb.  If the struct
 // underlying pb does not match the data in the buffer, the results can be
 // unpredictable.
+//
+// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal.
 func (p *Buffer) Unmarshal(pb Message) error {
 	// If the object can unmarshal itself, let it.
 	if u, ok := pb.(Unmarshaler); ok {