| ... | @@ -693,8 +693,8 @@ pub const DwarfInfo = struct { | ... | @@ -693,8 +693,8 @@ pub const DwarfInfo = struct { |
| 693 | } | 693 | } |
| 694 | | 694 | |
| 695 | pub fn deinit(di: *DwarfInfo, allocator: mem.Allocator) void { | 695 | pub fn deinit(di: *DwarfInfo, allocator: mem.Allocator) void { |
| 696 | for (di.sections) |s| { | 696 | for (di.sections) |opt_section| { |
| 697 | if (s.owned) allocator.free(s.data); | 697 | if (opt_section) |s| if (s.owned) allocator.free(s.data); |
| 698 | } | 698 | } |
| 699 | for (di.abbrev_table_list.items) |*abbrev| { | 699 | for (di.abbrev_table_list.items) |*abbrev| { |
| 700 | abbrev.deinit(); | 700 | abbrev.deinit(); |
| ... | @@ -1504,12 +1504,12 @@ pub const DwarfInfo = struct { | ... | @@ -1504,12 +1504,12 @@ pub const DwarfInfo = struct { |
| 1504 | | 1504 | |
| 1505 | while (stream.pos < stream.buffer.len) { | 1505 | while (stream.pos < stream.buffer.len) { |
| 1506 | const length_offset = stream.pos; | 1506 | const length_offset = stream.pos; |
| 1507 | var length: u64 = try reader.readInt(u32, di.endian); | 1507 | var length: usize = try reader.readInt(u32, di.endian); |
| 1508 | if (length == 0) break; | 1508 | if (length == 0) break; |
| 1509 | | 1509 | |
| 1510 | var is_64 = length == math.maxInt(u32); | 1510 | var is_64 = length == math.maxInt(u32); |
| 1511 | if (is_64) { | 1511 | if (is_64) { |
| 1512 | length = try reader.readInt(u64, di.endian); | 1512 | length = std.math.cast(usize, try reader.readInt(u64, di.endian)) orelse return error.LengthOverflow; |
| 1513 | } | 1513 | } |
| 1514 | | 1514 | |
| 1515 | const id_len = @as(u8, if (is_64) 8 else 4); | 1515 | const id_len = @as(u8, if (is_64) 8 else 4); |
| ... | @@ -1746,10 +1746,14 @@ fn readEhPointer(reader: anytype, enc: u8, addr_size_bytes: u8, ctx: EhPointerCo | ... | @@ -1746,10 +1746,14 @@ fn readEhPointer(reader: anytype, enc: u8, addr_size_bytes: u8, ctx: EhPointerCo |
| 1746 | }; | 1746 | }; |
| 1747 | | 1747 | |
| 1748 | if ((enc & EH.PE.indirect) > 0 and ctx.follow_indirect) { | 1748 | if ((enc & EH.PE.indirect) > 0 and ctx.follow_indirect) { |
| | 1749 | if (@sizeOf(usize) != addr_size_bytes) { |
| | 1750 | // See the documentation for `follow_indirect` |
| | 1751 | return error.NonNativeIndirection; |
| | 1752 | } |
| | 1753 | |
| | 1754 | const native_ptr = math.cast(usize, ptr) orelse return error.PointerOverflow; |
| 1749 | return switch (addr_size_bytes) { | 1755 | return switch (addr_size_bytes) { |
| 1750 | 2 => return @intToPtr(*const u16, ptr).*, | 1756 | 2, 4, 8 => return @intToPtr(*const usize, native_ptr).*, |
| 1751 | 4 => return @intToPtr(*const u32, ptr).*, | | |
| 1752 | 8 => return @intToPtr(*const u64, ptr).*, | | |
| 1753 | else => return error.UnsupportedAddrSize, | 1757 | else => return error.UnsupportedAddrSize, |
| 1754 | }; | 1758 | }; |
| 1755 | } else { | 1759 | } else { |
| ... | @@ -1960,7 +1964,7 @@ pub const FrameDescriptionEntry = struct { | ... | @@ -1960,7 +1964,7 @@ pub const FrameDescriptionEntry = struct { |
| 1960 | | 1964 | |
| 1961 | var aug_data: []const u8 = &[_]u8{}; | 1965 | var aug_data: []const u8 = &[_]u8{}; |
| 1962 | const lsda_pointer = if (cie.aug_str.len > 0) blk: { | 1966 | const lsda_pointer = if (cie.aug_str.len > 0) blk: { |
| 1963 | const aug_data_len = try leb.readULEB128(u64, reader); | 1967 | const aug_data_len = try leb.readULEB128(usize, reader); |
| 1964 | const aug_data_start = stream.pos; | 1968 | const aug_data_start = stream.pos; |
| 1965 | aug_data = fde_bytes[aug_data_start..][0..aug_data_len]; | 1969 | aug_data = fde_bytes[aug_data_start..][0..aug_data_len]; |
| 1966 | | 1970 | |