Skip to content

Commit 0d79bb6

Browse files
authored
fix: Handle nil internal buffer (#2226)
#### Summary `Bytes()` can panic if the internal `buf` is `nil`. This uses `Buf()` instead, see arrow code in https://github.com/apache/arrow-go/blob/b196d3b316d09f63786f021d4f1baa1fdd7620d2/arrow/memory/buffer.go#L108 ---
1 parent c4b5329 commit 0d79bb6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plugin/diff.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ func getUnifiedDiff(edits array.Edits, wantCol, haveCol arrow.Array) string {
2020
wantDataType := wantCol.DataType()
2121
wantData := make([]byte, wantCol.Len())
2222
for _, buffer := range wantCol.Data().Buffers() {
23-
wantData = append(wantData, buffer.Bytes()...)
23+
buf := buffer.Buf()
24+
if len(buf) > 0 {
25+
wantData = append(wantData, buf...)
26+
}
2427
}
2528
haveDataType := haveCol.DataType()
2629
haveData := make([]byte, haveCol.Len())
2730
for _, buffer := range haveCol.Data().Buffers() {
28-
haveData = append(haveData, buffer.Bytes()...)
31+
buf := buffer.Buf()
32+
if len(buf) > 0 {
33+
haveData = append(haveData, buf...)
34+
}
2935
}
3036

3137
wantBase64 := base64.StdEncoding.EncodeToString(wantData)

0 commit comments

Comments
 (0)