Skip to content

Commit de62bd0

Browse files
topolarityandrewrk
authored andcommitted
macho: Pass sections by pointer when slicing names
We were accidentally returning a pointer to stack memory, because these arguments were passed by value. It's just an accident that stage 1 was passing these by reference, so things were alright until stage 3.
1 parent 0efc6a3 commit de62bd0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/std/macho.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ pub const segment_command_64 = extern struct {
653653
nsects: u32 = 0,
654654
flags: u32 = 0,
655655

656-
pub fn segName(seg: segment_command_64) []const u8 {
656+
pub fn segName(seg: *const segment_command_64) []const u8 {
657657
return parseName(&seg.segname);
658658
}
659659
};
@@ -772,11 +772,11 @@ pub const section_64 = extern struct {
772772
/// reserved
773773
reserved3: u32 = 0,
774774

775-
pub fn sectName(sect: section_64) []const u8 {
775+
pub fn sectName(sect: *const section_64) []const u8 {
776776
return parseName(&sect.sectname);
777777
}
778778

779-
pub fn segName(sect: section_64) []const u8 {
779+
pub fn segName(sect: *const section_64) []const u8 {
780780
return parseName(&sect.segname);
781781
}
782782

0 commit comments

Comments
 (0)