Commit 40c400ec9e

fn ⌃ ⌥ <70830482+FnControlOption@users.noreply.github.com>
2023-01-17 17:47:22
std.crypto.Certificate.Bundle: clear bundle before macOS rescan
1 parent f3107e2
Changed files (1)
lib
std
crypto
Certificate
Bundle
lib/std/crypto/Certificate/Bundle/macos.zig
@@ -6,6 +6,9 @@ const Allocator = std.mem.Allocator;
 const Bundle = @import("../Bundle.zig");
 
 pub fn rescanMac(cb: *Bundle, gpa: Allocator) !void {
+    cb.bytes.clearRetainingCapacity();
+    cb.map.clearRetainingCapacity();
+
     const file = try fs.openFileAbsolute("/System/Library/Keychains/SystemRootCertificates.keychain", .{});
     defer file.close();
 
@@ -63,6 +66,8 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) !void {
             try cb.parseCert(gpa, cert_start, now_sec);
         }
     }
+
+    cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
 }
 
 const ApplDbHeader = extern struct {