File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ func (p *playerImpl) setBufferSize(bufferSize int) {
251
251
252
252
func (p * playerImpl ) getTmpBuf () ([]byte , func ()) {
253
253
// The returned buffer could be accessed regardless of the mutex m (#254).
254
- // In order to oavoid races, use a sync.Pool.
254
+ // In order to avoid races, use a sync.Pool.
255
255
// On the other hand, the calls of getTmpBuf itself should be protected by the mutex m,
256
256
// then accessing p.bufPool doesn't cause races.
257
257
if p .bufPool == nil {
@@ -264,6 +264,11 @@ func (p *playerImpl) getTmpBuf() ([]byte, func()) {
264
264
}
265
265
buf := p .bufPool .Get ().(* []byte )
266
266
return * buf , func () {
267
+ // p.bufPool could be nil when setBufferSize is called (#258).
268
+ // buf doesn't have to (or cannot) be put back to the pool, as the size of the buffer could be changed.
269
+ if p .bufPool == nil {
270
+ return
271
+ }
267
272
p .bufPool .Put (buf )
268
273
}
269
274
}
You can’t perform that action at this time.
0 commit comments