Skip to content

Commit 5535416

Browse files
committed
rpc_util: add capacity checks for all buffer pool sizes
- It's not required, as it's guaranteed outside the pool, but it seems safer.
1 parent fe1294f commit 5535416

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

shared_buffer_pool.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,8 @@ type bufferPool struct {
121121
func (p *bufferPool) Get(size int) []byte {
122122
bs := p.Pool.Get().(*[]byte)
123123

124-
// If default size is 0. It means this pool is fallback pool.
125-
// Therefore, we need to make a new one if the requested size is larger than the buffer.
126-
if p.defaultSize == 0 {
127-
if cap(*bs) < size {
128-
*bs = make([]byte, size)
129-
}
124+
if cap(*bs) < size {
125+
*bs = make([]byte, size)
130126
}
131127

132128
return (*bs)[:size]

0 commit comments

Comments
 (0)