Pārlūkot izejas kodu

Fix race in text formatting of oneof fields.

I was reparsing the oneof's struct field tag,
but not making a new Properties for it.
David Symonds 10 gadi atpakaļ
vecāks
revīzija
8df8a93c67
1 mainītis faili ar 2 papildinājumiem un 1 dzēšanām
  1. 2 1
      proto/text.go

+ 2 - 1
proto/text.go

@@ -334,7 +334,8 @@ func writeStruct(w *textWriter, sv reflect.Value) error {
 				}
 				}
 				inner := fv.Elem().Elem() // interface -> *T -> T
 				inner := fv.Elem().Elem() // interface -> *T -> T
 				tag := inner.Type().Field(0).Tag.Get("protobuf")
 				tag := inner.Type().Field(0).Tag.Get("protobuf")
-				props.Parse(tag) // Overwrite the outer props.
+				props = new(Properties) // Overwrite the outer props var, but not its pointee.
+				props.Parse(tag)
 				// Write the value in the oneof, not the oneof itself.
 				// Write the value in the oneof, not the oneof itself.
 				fv = inner.Field(0)
 				fv = inner.Field(0)