]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
When closing a file, call closedir if we called opendir.
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 28 Jan 2011 00:01:08 +0000 (00:01 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 28 Jan 2011 00:01:08 +0000 (00:01 +0000)
Fixes Go issue 1448.

From-SVN: r169344

libgo/go/os/file_unix.go

index aa322c96383570db20fb2e1b03f28db5b2a0d675..57d4a477fc6f63c6c34ee38a0e90f9d83f3f1f3e 100644 (file)
@@ -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