aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/g-os_lib.adb7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/ada/g-os_lib.adb b/gcc/ada/g-os_lib.adb
index dbfc6b9..c1efa03 100644
--- a/gcc/ada/g-os_lib.adb
+++ b/gcc/ada/g-os_lib.adb
@@ -384,7 +384,14 @@ package body GNAT.OS_Lib is
procedure Free is new Unchecked_Deallocation (Buf, Buf_Ptr);
begin
+ -- Check for invalid descriptors, making sure that we do not
+ -- accidentally leave an open file descriptor around.
+
if From = Invalid_FD then
+ if To /= Invalid_FD then
+ Close (To, Status_To);
+ end if;
+
raise Copy_Error;
elsif To = Invalid_FD then