[Ada] Fix memory leak in GNAT.Expect.Non_Blocking_Spawn on Windows
authorDmitriy Anisimkov <anisimko@adacore.com>
Sun, 29 Nov 2020 17:21:58 +0000 (23:21 +0600)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 16 Dec 2020 13:01:04 +0000 (08:01 -0500)
gcc/ada/

* libgnat/g-expect.adb (Non_Blocking_Spawn): Deallocate elements
on Arg_List after calling Set_Up_Child_Communications.

gcc/ada/libgnat/g-expect.adb

index 78b3c277f146b3c3b404a47e2b8dcece84d5b06e..0f9d0b9f96aff9871ae130a761925d5c3691f336 100644 (file)
@@ -1181,6 +1181,12 @@ package body GNAT.Expect is
          Set_Up_Child_Communications
            (Descriptor, Pipe1, Pipe2, Pipe3, Command_With_Path.all,
             C_Arg_List'Address);
+
+         --  On Windows systems we need to release memory taken for Arg_List
+
+         for A of Arg_List loop
+            Free (A);
+         end loop;
       end if;
 
       Free (Command_With_Path);