Commit fe61b19b96

zhylmzr <zhylmzr@gmail.com>
2024-03-02 17:46:55
macos: archive size fix
fixed: #19154
1 parent 3ea1276
Changed files (1)
src
link
src/link/MachO/Archive.zig
@@ -23,11 +23,11 @@ pub fn parse(self: *Archive, macho_file: *MachO, path: []const u8, handle_index:
 
     const handle = macho_file.getFileHandle(handle_index);
     const offset = if (fat_arch) |ar| ar.offset else 0;
-    const size = if (fat_arch) |ar| ar.size else (try handle.stat()).size;
+    const end_pos = if (fat_arch) |ar| offset + ar.size else (try handle.stat()).size;
 
     var pos: usize = offset + SARMAG;
     while (true) {
-        if (pos >= size) break;
+        if (pos >= end_pos) break;
         if (!mem.isAligned(pos, 2)) pos += 1;
 
         var hdr_buffer: [@sizeOf(ar_hdr)]u8 = undefined;