internal/impl: fix race ExtensionInfo.lazyInitSlow

The xi.init flag should not be set until after we have truly
initialized everything.

Change-Id: I43dcb300917145ce19a7199fa871acd0df325c6c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194439
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Joe Tsai 2019-09-09 16:52:28 -07:00
parent e87cf53d57
commit 2df47c918b

View File

@ -145,7 +145,7 @@ func (xi *ExtensionInfo) lazyInitSlow() {
if xi.init == extensionInfoFullInit {
return
}
atomic.StoreUint32(&xi.init, extensionInfoFullInit)
defer atomic.StoreUint32(&xi.init, extensionInfoFullInit)
if xi.desc == nil {
xi.initFromLegacy()