| author | |
| committer | |
| log | e5483b4ffc20614463e42741f132a55d58c01880 |
| tree | 4a2f59c14a2c9c84e47fb0ccffc7a1e3556b50da |
| parent | 8bd01eb7a914416a772b365dc75d83890067e26c |
2 files changed, 5 insertions(+), 3 deletions(-)
src/link/Elf.zig+2-2| ... | ... | @@ -5903,8 +5903,8 @@ fn fmtDumpState( |
| 5903 | 5903 | } |
| 5904 | 5904 | |
| 5905 | 5905 | /// Caller owns the memory. |
| 5906 | pub fn preadAllAlloc(allocator: Allocator, handle: std.fs.File, offset: usize, size: usize) ![]u8 { | |
| 5907 | const buffer = try allocator.alloc(u8, size); | |
| 5906 | pub fn preadAllAlloc(allocator: Allocator, handle: std.fs.File, offset: u64, size: u64) ![]u8 { | |
| 5907 | const buffer = try allocator.alloc(u8, math.cast(usize, size) orelse return error.Overflow); | |
| 5908 | 5908 | errdefer allocator.free(buffer); |
| 5909 | 5909 | const amt = try handle.preadAll(buffer, offset); |
| 5910 | 5910 | if (amt != size) return error.InputOutput; |
src/link/Elf/Object.zig+3-1| ... | ... | @@ -945,7 +945,9 @@ fn preadShdrContentsAlloc(self: Object, allocator: Allocator, handle: std.fs.Fil |
| 945 | 945 | assert(index < self.shdrs.items.len); |
| 946 | 946 | const offset = if (self.archive) |ar| ar.offset else 0; |
| 947 | 947 | const shdr = self.shdrs.items[index]; |
| 948 | return Elf.preadAllAlloc(allocator, handle, offset + shdr.sh_offset, shdr.sh_size); | |
| 948 | const sh_offset = math.cast(u64, shdr.sh_offset) orelse return error.Overflow; | |
| 949 | const sh_size = math.cast(u64, shdr.sh_size) orelse return error.Overflow; | |
| 950 | return Elf.preadAllAlloc(allocator, handle, offset + sh_offset, sh_size); | |
| 949 | 951 | } |
| 950 | 952 | |
| 951 | 953 | /// Caller owns the memory. |