Skip to content

Commit e8fc4e5

Browse files
committed
cap arraycontainer max growth at 8192
1 parent 8277a2a commit e8fc4e5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

arraycontainer.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,14 @@ func (ac *arrayContainer) iorArray(value2 *arrayContainer) container {
362362
if maxPossibleCardinality > cap(value1.content) {
363363
// doubling the capacity reduces new slice allocations in the case of
364364
// repeated calls to iorArray().
365-
newcontent := make([]uint16, 0, 2*maxPossibleCardinality)
365+
newSize := 2 * maxPossibleCardinality
366+
// the second check is to handle overly large array containers
367+
// and should not occur in normal usage,
368+
// as all array containers should be at most arrayDefaultMaxSize
369+
if newSize > 8192 && maxPossibleCardinality <= 8192 {
370+
newSize = 8192
371+
}
372+
newcontent := make([]uint16, 0, newSize)
366373
copy(newcontent[len2:maxPossibleCardinality], ac.content[0:len1])
367374
ac.content = newcontent
368375
} else {

0 commit comments

Comments
 (0)