| ... | @@ -85,8 +85,9 @@ pub fn write(list: AtomList, buffer: *std.ArrayList(u8), undefs: anytype, elf_fi | ... | @@ -85,8 +85,9 @@ pub fn write(list: AtomList, buffer: *std.ArrayList(u8), undefs: anytype, elf_fi |
| 85 | | 85 | |
| 86 | log.debug("writing atoms in section '{s}'", .{elf_file.getShString(osec.sh_name)}); | 86 | log.debug("writing atoms in section '{s}'", .{elf_file.getShString(osec.sh_name)}); |
| 87 | | 87 | |
| 88 | try buffer.ensureUnusedCapacity(list.size); | 88 | const list_size = math.cast(usize, list.size) orelse return error.Overflow; |
| 89 | buffer.appendNTimesAssumeCapacity(0, list.size); | 89 | try buffer.ensureUnusedCapacity(list_size); |
| | 90 | buffer.appendNTimesAssumeCapacity(0, list_size); |
| 90 | | 91 | |
| 91 | for (list.atoms.items) |ref| { | 92 | for (list.atoms.items) |ref| { |
| 92 | const atom_ptr = elf_file.atom(ref).?; | 93 | const atom_ptr = elf_file.atom(ref).?; |
| ... | @@ -120,8 +121,9 @@ pub fn writeRelocatable(list: AtomList, buffer: *std.ArrayList(u8), elf_file: *E | ... | @@ -120,8 +121,9 @@ pub fn writeRelocatable(list: AtomList, buffer: *std.ArrayList(u8), elf_file: *E |
| 120 | | 121 | |
| 121 | log.debug("writing atoms in section '{s}'", .{elf_file.getShString(osec.sh_name)}); | 122 | log.debug("writing atoms in section '{s}'", .{elf_file.getShString(osec.sh_name)}); |
| 122 | | 123 | |
| 123 | try buffer.ensureUnusedCapacity(list.size); | 124 | const list_size = math.cast(usize, list.size) orelse return error.Overflow; |
| 124 | buffer.appendNTimesAssumeCapacity(0, list.size); | 125 | try buffer.ensureUnusedCapacity(list_size); |
| | 126 | buffer.appendNTimesAssumeCapacity(0, list_size); |
| 125 | | 127 | |
| 126 | for (list.atoms.items) |ref| { | 128 | for (list.atoms.items) |ref| { |
| 127 | const atom_ptr = elf_file.atom(ref).?; | 129 | const atom_ptr = elf_file.atom(ref).?; |