mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user