Fix struct copy and invalid pointer access in Link.path()

Interesting case of
https://ziglang.org/download/0.10.0/release-notes.html#Escaped-Pointer-to-Parameter
This commit is contained in:
Yorhel 2022-11-02 14:51:22 +01:00
parent 890e5a4af7
commit 4d124c7c3d

View file

@ -276,7 +276,7 @@ pub const Link = extern struct {
name: [0]u8 = undefined,
// Return value should be freed with main.allocator.
pub fn path(self: @This(), withRoot: bool) [:0]const u8 {
pub fn path(self: *const @This(), withRoot: bool) [:0]const u8 {
var out = std.ArrayList(u8).init(main.allocator);
self.parent.fmtPath(withRoot, &out);
out.append('/') catch unreachable;