]> Cypherpunks repositories - gostls13.git/commit
sync: don't keep func alive after OnceFunc panics
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Tue, 25 Feb 2025 20:07:12 +0000 (20:07 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 26 Feb 2025 20:52:02 +0000 (12:52 -0800)
commitee0d03fab6e38dc3f8d10032e7c30c68ac7ec066
tree244186966f8523cd5bd23054f8f19b432869809d
parent1421b982dca738daf47fe11aec9b56050798d739
sync: don't keep func alive after OnceFunc panics

This moves the f = nil assignment to the defer statement,
so that in case the functions panics, the f func is not
referenced anymore.

Change-Id: I3e53b90a10f21741e26602270822c8a75679f163
GitHub-Last-Rev: bda01100c6d48d1b0ca3e1baefef4d592cca1fee
GitHub-Pull-Request: golang/go#68636
Reviewed-on: https://go-review.googlesource.com/c/go/+/601240
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
src/sync/oncefunc.go
src/sync/oncefunc_test.go