aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-01-28 00:01:08 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-01-28 00:01:08 +0000
commitb91b9ad43e67a984fef611ec9d5df0bfb226f35b (patch)
treef4236633c9d7e06df075266f39a9ff7f6c28a1cd /libgo
parent75d0b39856c3cb3346f2978910cfd7e4285e4013 (diff)
downloadgcc-b91b9ad43e67a984fef611ec9d5df0bfb226f35b.zip
gcc-b91b9ad43e67a984fef611ec9d5df0bfb226f35b.tar.gz
gcc-b91b9ad43e67a984fef611ec9d5df0bfb226f35b.tar.bz2
When closing a file, call closedir if we called opendir.
Fixes Go issue 1448. From-SVN: r169344
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/os/file_unix.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/libgo/go/os/file_unix.go b/libgo/go/os/file_unix.go
index aa322c9..57d4a47 100644
--- a/libgo/go/os/file_unix.go
+++ b/libgo/go/os/file_unix.go
@@ -47,6 +47,13 @@ func (file *File) Close() Error {
if e := syscall.Close(file.fd); e != 0 {
err = &PathError{"close", file.name, Errno(e)}
}
+
+ if file.dirinfo != nil {
+ if libc_closedir(file.dirinfo.dir) < 0 && err == nil {
+ err = &PathError{"closedir", file.name, Errno(syscall.GetErrno())}
+ }
+ }
+
file.fd = -1 // so it can't be closed again
// no need for a finalizer anymore