zeroshade commented on code in PR #1232:
URL: https://github.com/apache/arrow-go/pull/1232#discussion_r3882540544


##########
arrow/array/binarybuilder.go:
##########
@@ -606,10 +606,14 @@ func (b *BinaryViewBuilder) AppendNull() {
 }
 
 func (b *BinaryViewBuilder) AppendNulls(n int) {
-       b.Reserve(n)
-       for i := 0; i < n; i++ {
-               b.UnsafeAppendBoolToBitmap(false)
+       if n <= 0 {
+               return
        }
+
+       b.Reserve(n)

Review Comment:
   Please reject counts that would overflow `b.length + n` before calling 
`Reserve`.
   
   With one existing value, `AppendNulls(math.MaxInt)` now returns with `Len() 
== math.MinInt` and `NullN() == math.MaxInt`. `NewBinaryViewArray()` then 
produces a negative-length array whose `ValidateFull()` still returns nil. A 
guard such as `n > math.MaxInt-b.length`, plus boundary regression coverage, 
would prevent this silent corruption.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to