From efb8146c286881cf3a7d432527a651dc0d850989 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 6 Apr 2024 10:20:16 -0700 Subject: [PATCH] config: RepeatableString.clone should clone all the strings too --- src/config/Config.zig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config/Config.zig b/src/config/Config.zig index 6ca64ca01..eb4f21d18 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -2498,9 +2498,14 @@ pub const RepeatableString = struct { /// Deep copy of the struct. Required by Config. pub fn clone(self: *const Self, alloc: Allocator) !Self { - return .{ - .list = try self.list.clone(alloc), - }; + // Copy the list and all the strings in the list. + const list = try self.list.clone(alloc); + for (list.items) |*item| { + const copy = try alloc.dupeZ(u8, item.*); + item.* = copy; + } + + return .{ .list = list }; } /// The number of itemsin the list