Skip to content

Commit d8c8131

Browse files
awillenbuecher-xq-tecLarsAsplund
authored andcommitted
Fixed memory leak of location_t.file_name.
1 parent c16718d commit d8c8131

5 files changed

+15
-0
lines changed

vunit/vhdl/check/src/checker_pkg-body.vhd

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ package body checker_pkg is
152152
check_result.p_msg := new_string_ptr(string_pool, p_std_msg(std_fail_msg, msg, std_fail_ctx));
153153
end if;
154154

155+
deallocate(location);
155156
return check_result;
156157
end;
157158

vunit/vhdl/logging/src/location_pkg-body-2008m.vhd

+5
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ package body location_pkg is
1313

1414
return result;
1515
end;
16+
17+
procedure deallocate(variable location : inout location_t) is
18+
begin
19+
deallocate(location.file_name);
20+
end;
1621
end package body;

vunit/vhdl/logging/src/location_pkg-body-2019p.vhd

+5
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ package body location_pkg is
2929
swrite(result.file_name, "");
3030
return result;
3131
end;
32+
33+
procedure deallocate(variable location : inout location_t) is
34+
begin
35+
deallocate(location.file_name);
36+
end;
3237
end package body;

vunit/vhdl/logging/src/location_pkg.vhd

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ package location_pkg is
1212
end record;
1313

1414
impure function get_location(path_offset, line_num : natural; file_name : string) return location_t;
15+
procedure deallocate(variable location : inout location_t);
1516
end package;

vunit/vhdl/logging/src/logger_pkg-body.vhd

+3
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ package body logger_pkg is
878878
begin
879879
if logger = null_logger then
880880
core_failure("Attempt to log to uninitialized logger");
881+
deallocate(location);
881882
return;
882883
end if;
883884

@@ -902,6 +903,8 @@ package body logger_pkg is
902903
-- Count even if disabled
903904
count_log(logger, log_level);
904905
end if;
906+
907+
deallocate(location);
905908
end procedure;
906909

907910
procedure debug(logger : logger_t;

0 commit comments

Comments
 (0)