diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 5c56490519..b27b1caa68 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -825,8 +825,15 @@ pub fn openElfDebugInfo(allocator: *mem.Allocator, elf_file_path: []const u8) !M const shoff = hdr.e_shoff; const str_section_off = shoff + @as(u64, hdr.e_shentsize) * @as(u64, hdr.e_shstrndx); - const header_strings = mapped_mem[str_section_off..str_section_off + hdr.e_shentsize]; - const shdrs = @ptrCast([*]const elf.Shdr, @alignCast(@alignOf(elf.Shdr), &mapped_mem[shoff]))[0..hdr.e_shnum]; + const str_shdr = @ptrCast( + *const elf.Shdr, + @alignCast(@alignOf(elf.Shdr), &mapped_mem[str_section_off]), + ); + const header_strings = mapped_mem[str_shdr.sh_offset .. str_shdr.sh_offset + str_shdr.sh_size]; + const shdrs = @ptrCast( + [*]const elf.Shdr, + @alignCast(@alignOf(elf.Shdr), &mapped_mem[shoff]), + )[0..hdr.e_shnum]; var opt_debug_info: ?[]const u8 = null; var opt_debug_abbrev: ?[]const u8 = null; diff --git a/lib/std/io/fixed_buffer_stream.zig b/lib/std/io/fixed_buffer_stream.zig index 9cdad7dc57..0f2b542201 100644 --- a/lib/std/io/fixed_buffer_stream.zig +++ b/lib/std/io/fixed_buffer_stream.zig @@ -164,6 +164,5 @@ test "FixedBufferStream input" { testing.expect(read == 3); testing.expect(mem.eql(u8, dest[0..3], bytes[4..7])); - read = try fbs.inStream().read(dest[0..4]); - testing.expect(read == 0); + testing.expectError(error.EndOfStream, fbs.inStream().read(dest[0..4])); }