From 7cdf07e36e3785afa797f5ef753f478dbfb3ea31 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Thu, 11 Dec 2025 02:51:27 +0000 Subject: [PATCH] fix: Add deinit for bundler_feature_flags to prevent memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update BundleOptions.deinit to free bundler_feature_flags if allocated - Skip freeing static empty_bundler_feature_flags constant - Pass allocator to deinit from Transpiler.deinit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/options.zig | 7 ++++++- src/transpiler.zig | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/options.zig b/src/options.zig index 3de2f29902..35972145fe 100644 --- a/src/options.zig +++ b/src/options.zig @@ -1909,8 +1909,13 @@ pub const BundleOptions = struct { this.defines_loaded = true; } - pub fn deinit(this: *const BundleOptions) void { + pub fn deinit(this: *BundleOptions, allocator: std.mem.Allocator) void { this.define.deinit(); + // Free bundler_feature_flags if it was allocated (not the static empty set) + if (this.bundler_feature_flags != &Runtime.Features.empty_bundler_feature_flags) { + @constCast(this.bundler_feature_flags).deinit(); + allocator.destroy(@constCast(this.bundler_feature_flags)); + } } pub fn loader(this: *const BundleOptions, ext: string) Loader { diff --git a/src/transpiler.zig b/src/transpiler.zig index 209f35804c..34990315a0 100644 --- a/src/transpiler.zig +++ b/src/transpiler.zig @@ -438,7 +438,7 @@ pub const Transpiler = struct { } pub fn deinit(this: *Transpiler) void { - this.options.deinit(); + this.options.deinit(this.allocator); this.log.deinit(); this.resolver.deinit(); this.fs.deinit();