aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2006-02-17 17:07:10 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2006-02-17 17:07:10 +0100
commit0e3e1f1559c7608c6b736fe9c6d30c07425dfd83 (patch)
tree804e9e64b2a5e7fe5ad8d29faf2e4a2b96cb5ae0 /gcc/ada
parent7f9747c61d1bac65d73216c41b83db17cb861561 (diff)
downloadgcc-0e3e1f1559c7608c6b736fe9c6d30c07425dfd83.zip
gcc-0e3e1f1559c7608c6b736fe9c6d30c07425dfd83.tar.gz
gcc-0e3e1f1559c7608c6b736fe9c6d30c07425dfd83.tar.bz2
g-os_lib.adb (Copy_File): Make sure that if From has an Invalid_FD, then we close To if it is valid.
2006-02-17 Robert Dewar <dewar@adacore.com> * g-os_lib.adb (Copy_File): Make sure that if From has an Invalid_FD, then we close To if it is valid. From-SVN: r111188
Diffstat (limited to 'gcc/ada')
-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