Skip to content

Commit

Permalink
Fixed memory leak of location_t.file_name.
Browse files Browse the repository at this point in the history
  • Loading branch information
awillenbuecher-xq-tec authored and LarsAsplund committed Nov 19, 2023
1 parent c16718d commit d8c8131
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions vunit/vhdl/check/src/checker_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ package body checker_pkg is
check_result.p_msg := new_string_ptr(string_pool, p_std_msg(std_fail_msg, msg, std_fail_ctx));
end if;

deallocate(location);
return check_result;
end;

Expand Down
5 changes: 5 additions & 0 deletions vunit/vhdl/logging/src/location_pkg-body-2008m.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ package body location_pkg is

return result;
end;

procedure deallocate(variable location : inout location_t) is
begin
deallocate(location.file_name);
end;
end package body;
5 changes: 5 additions & 0 deletions vunit/vhdl/logging/src/location_pkg-body-2019p.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ package body location_pkg is
swrite(result.file_name, "");
return result;
end;

procedure deallocate(variable location : inout location_t) is
begin
deallocate(location.file_name);
end;
end package body;
1 change: 1 addition & 0 deletions vunit/vhdl/logging/src/location_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ package location_pkg is
end record;

impure function get_location(path_offset, line_num : natural; file_name : string) return location_t;
procedure deallocate(variable location : inout location_t);
end package;
3 changes: 3 additions & 0 deletions vunit/vhdl/logging/src/logger_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ package body logger_pkg is
begin
if logger = null_logger then
core_failure("Attempt to log to uninitialized logger");
deallocate(location);
return;
end if;

Expand All @@ -902,6 +903,8 @@ package body logger_pkg is
-- Count even if disabled
count_log(logger, log_level);
end if;

deallocate(location);
end procedure;

procedure debug(logger : logger_t;
Expand Down

0 comments on commit d8c8131

Please sign in to comment.