Fix memory leaks

This commit is contained in:
ktkk 2026-06-23 20:53:14 +02:00
parent e6f1f6f9ea
commit e04cc8cc66

View file

@ -1378,9 +1378,9 @@ pub const AttributeInfo = struct {
pub fn deinit(self: *ElementValue, allocator: std.mem.Allocator) void {
switch (self.*) {
.annotation_value => |element_value| element_value.deinit(allocator),
.annotation_value => |*element_value| element_value.deinit(allocator),
.array_value => |element_value| {
for (element_value.values) |value| {
for (element_value.values) |*value| {
value.deinit(allocator);
}
allocator.free(element_value.values);
@ -1481,16 +1481,32 @@ pub const AttributeInfo = struct {
.line_number_table => |attribute| allocator.free(attribute.line_number_table),
.local_variable_table => |attribute| allocator.free(attribute.local_variable_table),
.local_variable_type_table => |attribute| allocator.free(attribute.local_variable_type_table),
.runtime_visible_annotations => |attribute| allocator.free(attribute.annotations),
.runtime_invisible_annotations => |attribute| allocator.free(attribute.annotations),
.runtime_visible_annotations => |attribute| {
for (attribute.annotations) |*annotation| {
annotation.deinit(allocator);
}
allocator.free(attribute.annotations);
},
.runtime_invisible_annotations => |attribute| {
for (attribute.annotations) |*annotation| {
annotation.deinit(allocator);
}
allocator.free(attribute.annotations);
},
.runtime_visible_parameter_annotations => |attribute| {
for (attribute.parameter_annotations) |parameter_annotation| {
for (parameter_annotation.annotations) |*annotation| {
annotation.deinit(allocator);
}
allocator.free(parameter_annotation.annotations);
}
allocator.free(attribute.parameter_annotations);
},
.runtime_invisible_parameter_annotations => |attribute| {
for (attribute.parameter_annotations) |parameter_annotation| {
for (parameter_annotation.annotations) |*annotation| {
annotation.deinit(allocator);
}
allocator.free(parameter_annotation.annotations);
}
allocator.free(attribute.parameter_annotations);