authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-07-19 23:31:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-20 03:45:29-04:00
logde62bd06472e5603fd2afb6f50d688d54f4098b4
tree3943dc865e71007aa56d2bc6615af3f711dbd1e0
parent0efc6a35bead74b5faffbc87b446b5087f1bb99b

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 files changed, 3 insertions(+), 3 deletions(-)

lib/std/macho.zig+3-3
...@@ -653,7 +653,7 @@ pub const segment_command_64 = extern struct {...@@ -653,7 +653,7 @@ pub const segment_command_64 = extern struct {
653 nsects: u32 = 0,653 nsects: u32 = 0,
654 flags: u32 = 0,654 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 {
657 return parseName(&seg.segname);657 return parseName(&seg.segname);
658 }658 }
659};659};
...@@ -772,11 +772,11 @@ pub const section_64 = extern struct {...@@ -772,11 +772,11 @@ pub const section_64 = extern struct {
772 /// reserved772 /// reserved
773 reserved3: u32 = 0,773 reserved3: u32 = 0,
774774
775 pub fn sectName(sect: section_64) []const u8 {775 pub fn sectName(sect: *const section_64) []const u8 {
776 return parseName(&sect.sectname);776 return parseName(&sect.sectname);
777 }777 }
778778
779 pub fn segName(sect: section_64) []const u8 {779 pub fn segName(sect: *const section_64) []const u8 {
780 return parseName(&sect.segname);780 return parseName(&sect.segname);
781 }781 }
782782