diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2021-10-31 21:45:32 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-11-01 15:08:41 -0400 |
| commit | 70ef9bc75c42ec00e9d4231a2e1f1dca84144748 (patch) | |
| tree | e172783da32798ca11c3b28c43cbcffb05fbf9d5 /src/link/MachO/Dylib.zig | |
| parent | 77eefebe65fc2baed08755bceb8e4df77fe8103c (diff) | |
| download | zig-70ef9bc75c42ec00e9d4231a2e1f1dca84144748.tar.gz zig-70ef9bc75c42ec00e9d4231a2e1f1dca84144748.zip | |
Fix ensureTotalCapacity calls that should be ensureUnusedCapacity calls
If these functions are called more than once, then the array list would no longer be guaranteed to have enough capacity during the appendAssumeCapacity calls. With ensureUnusedCapacity, they will always be guaranteed to have enough capacity regardless of how many times the function is called.
Diffstat (limited to 'src/link/MachO/Dylib.zig')
| -rw-r--r-- | src/link/MachO/Dylib.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig index e3998a8548..5b4ab6aa18 100644 --- a/src/link/MachO/Dylib.zig +++ b/src/link/MachO/Dylib.zig @@ -180,7 +180,7 @@ pub fn parse(self: *Dylib, allocator: *Allocator, target: std.Target) !void { fn readLoadCommands(self: *Dylib, allocator: *Allocator, reader: anytype) !void { const should_lookup_reexports = self.header.?.flags & macho.MH_NO_REEXPORTED_DYLIBS == 0; - try self.load_commands.ensureTotalCapacity(allocator, self.header.?.ncmds); + try self.load_commands.ensureUnusedCapacity(allocator, self.header.?.ncmds); var i: u16 = 0; while (i < self.header.?.ncmds) : (i += 1) { |
