From: ian Date: Fri, 28 Jan 2011 00:01:08 +0000 (+0000) Subject: When closing a file, call closedir if we called opendir. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a20d79f7d50b067cdac522211e59c704dfdefa9e;p=thirdparty%2Fgcc.git When closing a file, call closedir if we called opendir. Fixes Go issue 1448. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169344 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libgo/go/os/file_unix.go b/libgo/go/os/file_unix.go index aa322c963835..57d4a477fc6f 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