| ... | @@ -169,13 +169,16 @@ pub fn getAtomData(self: *const InternalObject, atom: Atom, buffer: []u8) !void | ... | @@ -169,13 +169,16 @@ pub fn getAtomData(self: *const InternalObject, atom: Atom, buffer: []u8) !void |
| 169 | const slice = self.sections.slice(); | 169 | const slice = self.sections.slice(); |
| 170 | const sect = slice.items(.header)[atom.n_sect]; | 170 | const sect = slice.items(.header)[atom.n_sect]; |
| 171 | const extra = slice.items(.extra)[atom.n_sect]; | 171 | const extra = slice.items(.extra)[atom.n_sect]; |
| 172 | const data = if (extra.is_objc_methname) | 172 | const data = if (extra.is_objc_methname) blk: { |
| 173 | self.objc_methnames.items[sect.offset..][0..sect.size] | 173 | const size = std.math.cast(usize, sect.size) orelse return error.Overflow; |
| 174 | else if (extra.is_objc_selref) | 174 | break :blk self.objc_methnames.items[sect.offset..][0..size]; |
| | 175 | } else if (extra.is_objc_selref) |
| 175 | &self.objc_selrefs | 176 | &self.objc_selrefs |
| 176 | else | 177 | else |
| 177 | @panic("ref to non-existent section"); | 178 | @panic("ref to non-existent section"); |
| 178 | @memcpy(buffer, data[atom.off..][0..atom.size]); | 179 | const off = std.math.cast(usize, atom.off) orelse return error.Overflow; |
| | 180 | const size = std.math.cast(usize, atom.size) orelse return error.Overflow; |
| | 181 | @memcpy(buffer, data[off..][0..size]); |
| 179 | } | 182 | } |
| 180 | | 183 | |
| 181 | pub fn getAtomRelocs(self: *const InternalObject, atom: Atom) []const Relocation { | 184 | pub fn getAtomRelocs(self: *const InternalObject, atom: Atom) []const Relocation { |