From: Robert Dewar Date: Fri, 17 Feb 2006 16:07:10 +0000 (+0100) Subject: g-os_lib.adb (Copy_File): Make sure that if From has an Invalid_FD, then we close... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e3e1f1559c7608c6b736fe9c6d30c07425dfd83;p=gcc.git 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 * 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 --- diff --git a/gcc/ada/g-os_lib.adb b/gcc/ada/g-os_lib.adb index dbfc6b91745..c1efa039092 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