This is an automated email from the ASF dual-hosted git repository.

quinnj pushed a commit to branch jq-437
in repository https://gitbox.apache.org/repos/asf/arrow-julia.git

commit 0b0c8bec2a64ece2ceb255f9867cc0381c89488e
Author: Jacob Quinn <[email protected]>
AuthorDate: Fri Jun 2 23:29:04 2023 -0600

    Fix case where compressed file reports non-zero buffer length
    
    Fixes #437. Thanks to @DrChainsaw for the investigation, proposed fix,
    and test file.
---
 src/table.jl                           |   5 ++---
 test/java_compressed_zero_length.arrow | Bin 0 -> 746 bytes
 test/runtests.jl                       |   8 ++++++++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/table.jl b/src/table.jl
index 50bcd3b..ada392d 100644
--- a/src/table.jl
+++ b/src/table.jl
@@ -570,10 +570,9 @@ function buildbitmap(batch, rb, nodeidx, bufferidx)
 end
 
 function uncompress(ptr::Ptr{UInt8}, buffer, compression)
-    if buffer.length == 0
-        return 0, UInt8[]
-    end
+    buffer.length == 0 && return 0, UInt8[]
     len = unsafe_load(convert(Ptr{Int64}, ptr))
+    len == 0 && return 0, UInt8[]
     ptr += 8 # skip past uncompressed length as Int64
     encodedbytes = unsafe_wrap(Array, ptr, buffer.length - 8)
     if len == -1
diff --git a/test/java_compressed_zero_length.arrow 
b/test/java_compressed_zero_length.arrow
new file mode 100644
index 0000000..36345e1
Binary files /dev/null and b/test/java_compressed_zero_length.arrow differ
diff --git a/test/runtests.jl b/test/runtests.jl
index 12c826c..4f84e7c 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -690,6 +690,14 @@ end
 
 end
 
+@testset "# 437" begin
+
+t = Arrow.Table(joinpath(dirname(pathof(Arrow)), 
"../test/java_compressed_zero_length.arrow"))
+@test length(t) == 2
+@test length(t.name) == 0
+
+end
+
 end # @testset "misc"
 
 end

Reply via email to