Skip to content

Commit 0a70fc1

Browse files
topolarityclaude
andcommitted
Fix readmeta(io, FatMachOHandle) for IOBuffers on 32-bit
`position()` of an `IOBuffer` is an `Int`, which on 32-bit platforms does not match the `Int64` start of a `FatMachOHandle`. Convert it, as the other handle types already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b638f54 commit 0a70fc1

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/MachO/MachOFat.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function readmeta(io::IO,::Type{FatMachOHandle})
5959

6060
# Unpack the header
6161
header = unpack(io, header_type, endianness)
62-
return FatMachOHandle(io, start, header, path(io))
62+
return FatMachOHandle(io, Int64(start), header, path(io))
6363
end
6464

6565
# Iteration

‎test/runtests.jl‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function test_libfoo_and_fooifier(fooifier_path, libfoo_path)
207207
end
208208

209209
function test_fat_libfoo(file)
210-
ohs = readmeta(open(file, "r"))
210+
ohs = readmeta(file isa IO ? file : open(file, "r"))
211211
@test isa(ohs, FatMachOHandle)
212212
@test length(ohs) == 2
213213
ntotal, n64 = 0, 0
@@ -245,7 +245,9 @@ test_libfoo_and_fooifier("./linux64/fooifier", "./linux64/libfoo.so")
245245
# Run MachO tests
246246
test_libfoo_and_fooifier("./mac64/fooifier", "./mac64/libfoo.dylib")
247247
test_fat_libfoo("./mac64/libfoo_fat.dylib")
248+
test_fat_libfoo(IOBuffer(read("./mac64/libfoo_fat.dylib")))
248249
test_fat_libfoo("./mac64/libfoo_fat64.dylib")
250+
test_fat_libfoo(IOBuffer(read("./mac64/libfoo_fat64.dylib")))
249251
test_metal("./macmetal/dummy")
250252

251253
# Run COFF tests

0 commit comments

Comments
 (0)