zld: fix parsing archive/object name from header

This commit is contained in:
Jakub Konka 2021-03-19 08:46:43 +01:00
parent 96ae451bbe
commit d1b376cac9

View File

@ -248,8 +248,8 @@ fn getName(allocator: *Allocator, header: ar_hdr, reader: anytype) ![]u8 {
var n = try allocator.alloc(u8, len); var n = try allocator.alloc(u8, len);
defer allocator.free(n); defer allocator.free(n);
try reader.readNoEof(n); try reader.readNoEof(n);
const actual_len = mem.indexOfScalar(u8, n, @as(u8, 0)); const actual_len = mem.indexOfScalar(u8, n, @as(u8, 0)) orelse n.len;
name = try allocator.dupe(u8, n[0..actual_len.?]); name = try allocator.dupe(u8, n[0..actual_len]);
}, },
} }
return name; return name;