fix: Add deinit for bundler_feature_flags to prevent memory leak

- 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 <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2025-12-11 02:51:27 +00:00
parent f1789680b4
commit 7cdf07e36e
2 changed files with 7 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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();