This is an automated email from the ASF dual-hosted git repository.
curth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-dotnet.git
The following commit(s) were added to refs/heads/main by this push:
new 56a9a5e Use unsigned long integers for computing bit-length of
fixed-width types via the CData ABI (#251)
56a9a5e is described below
commit 56a9a5e53e9fa52224a678e7f2e504bb4399de58
Author: Joshua Klein <[email protected]>
AuthorDate: Mon Feb 2 10:10:53 2026 -0500
Use unsigned long integers for computing bit-length of fixed-width types
via the CData ABI (#251)
## What's Changed
Uses unsigned 64-bit integers to compute the intermediate bit length of
an array to avoid arithmetic overflow.
I could factorize this expression differently to avoid the casts, but I
didn't think this was a sufficiently heavy code path that it'd need more
attention.
Closes #250 .
---------
Co-authored-by: Adam Reeve <[email protected]>
---
src/Apache.Arrow/C/CArrowArrayImporter.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/Apache.Arrow/C/CArrowArrayImporter.cs
b/src/Apache.Arrow/C/CArrowArrayImporter.cs
index c454380..2dc4adb 100644
--- a/src/Apache.Arrow/C/CArrowArrayImporter.cs
+++ b/src/Apache.Arrow/C/CArrowArrayImporter.cs
@@ -470,7 +470,10 @@ namespace Apache.Arrow.C
int length = checked((int)cArray->offset +
(int)cArray->length);
int valuesLength;
if (bitWidth >= 8)
- valuesLength = checked(length * bitWidth / 8);
+ {
+ Debug.Assert(bitWidth % 8 == 0);
+ valuesLength = checked((int)((ulong)length *
(ulong)bitWidth / 8ul));
+ }
else
valuesLength =
checked((int)BitUtility.RoundUpToMultipleOf8(length) / 8);