File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ const (
13
13
Size = 8192
14
14
)
15
15
16
+ var zero = [Size * 10 ]byte {0 }
17
+
16
18
var pool = bytespool .GetPool (Size )
17
19
18
20
// ownership represents the data owner of the buffer.
@@ -150,6 +152,7 @@ func (b *Buffer) Extend(n int32) []byte {
150
152
}
151
153
ext := b .v [b .end :end ]
152
154
b .end = end
155
+ copy (ext , zero [:])
153
156
return ext
154
157
}
155
158
@@ -198,6 +201,7 @@ func (b *Buffer) Check() {
198
201
199
202
// Resize cuts the buffer at the given position.
200
203
func (b * Buffer ) Resize (from , to int32 ) {
204
+ oldEnd := b .end
201
205
if from < 0 {
202
206
from += b .Len ()
203
207
}
@@ -210,6 +214,9 @@ func (b *Buffer) Resize(from, to int32) {
210
214
b .end = b .start + to
211
215
b .start += from
212
216
b .Check ()
217
+ if b .end > oldEnd {
218
+ copy (b .v [oldEnd :b .end ], zero [:])
219
+ }
213
220
}
214
221
215
222
// Advance cuts the buffer at the given position.
You can’t perform that action at this time.
0 commit comments