aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-04 18:48:38 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-04 18:48:38 +0100
commitb1aa6c0603351edaf0f07bacc73ded539d16ee57 (patch)
treee0b38d8158e8c9e0106dc379632eaaf05877cee1 /src
parent61d4cdf2c6e2c5f686a9256ce5cf51de5bf37f8c (diff)
downloadghdl-b1aa6c0603351edaf0f07bacc73ded539d16ee57.tar.gz
ghdl-b1aa6c0603351edaf0f07bacc73ded539d16ee57.tar.bz2
ghdl-b1aa6c0603351edaf0f07bacc73ded539d16ee57.zip
ghdlmain: fix deallocation in response file handling.
Diffstat (limited to 'src')
-rw-r--r--src/ghdldrv/ghdlmain.adb10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ghdldrv/ghdlmain.adb b/src/ghdldrv/ghdlmain.adb
index a022464d5..00b09bb30 100644
--- a/src/ghdldrv/ghdlmain.adb
+++ b/src/ghdldrv/ghdlmain.adb
@@ -430,6 +430,8 @@ package body Ghdlmain is
Rsp_Arg : constant String_Access := Args (Arg_Index);
Rsp_File : constant String := Rsp_Arg (2 .. Rsp_Arg'Last);
begin
+ -- Need a second declare block so that the exception handler
+ -- can use Rsp_File.
declare
Exp_Args : constant GNAT.OS_Lib.Argument_List :=
Response_File.Arguments_From (Rsp_File);
@@ -438,12 +440,20 @@ package body Ghdlmain is
begin
New_Args :=
new String_List (1 .. Args'Last + Exp_Length - 1);
+
+ -- Copy arguments from the response file.
New_Args (1 .. Arg_Index - 1) := Args (1 .. Arg_Index - 1);
New_Args (Arg_Index .. Arg_Index + Exp_Length - 1) :=
Exp_Args;
New_Args (Arg_Index + Exp_Length .. New_Args'Last) :=
Args (Arg_Index + 1 .. Args'Last);
+
+ -- Free array. Note: Free deallocates both the array and
+ -- its elements. But we need to keep the elements.
+ Args.all := (others => null);
+ Args (Arg_Index) := Rsp_Arg;
Free (Args);
+
Args := New_Args;
Arg_Index := Arg_Index + Exp_Length;
end;