Skip to content

Commit a2c7112

Browse files
niaowdeadprogram
authored andcommitted
properly handle nil New func in sync.Pool
1 parent 3eec878 commit a2c7112

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/sync/pool.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ type Pool struct {
88

99
// Get returns the value of calling Pool.New().
1010
func (p *Pool) Get() interface{} {
11+
if p.New == nil {
12+
return nil
13+
}
1114
return p.New()
1215
}
1316

0 commit comments

Comments
 (0)