| ... | @@ -23,11 +23,11 @@ pub fn parse(self: *Archive, macho_file: *MachO, path: []const u8, handle_index: | ... | @@ -23,11 +23,11 @@ pub fn parse(self: *Archive, macho_file: *MachO, path: []const u8, handle_index: |
| 23 | | 23 | |
| 24 | const handle = macho_file.getFileHandle(handle_index); | 24 | const handle = macho_file.getFileHandle(handle_index); |
| 25 | const offset = if (fat_arch) |ar| ar.offset else 0; | 25 | const offset = if (fat_arch) |ar| ar.offset else 0; |
| 26 | const size = if (fat_arch) |ar| ar.size else (try handle.stat()).size; | 26 | const end_pos = if (fat_arch) |ar| offset + ar.size else (try handle.stat()).size; |
| 27 | | 27 | |
| 28 | var pos: usize = offset + SARMAG; | 28 | var pos: usize = offset + SARMAG; |
| 29 | while (true) { | 29 | while (true) { |
| 30 | if (pos >= size) break; | 30 | if (pos >= end_pos) break; |
| 31 | if (!mem.isAligned(pos, 2)) pos += 1; | 31 | if (!mem.isAligned(pos, 2)) pos += 1; |
| 32 | | 32 | |
| 33 | var hdr_buffer: [@sizeOf(ar_hdr)]u8 = undefined; | 33 | var hdr_buffer: [@sizeOf(ar_hdr)]u8 = undefined; |