Patchwork libgo patch committed: If we called opendir, call closedir

login
register
mail settings
Submitter Ian Taylor
Date Jan. 28, 2011, 12:01 a.m.
Message ID <mcr39odoq0p.fsf@google.com>
Download mbox | patch
Permalink /patch/80756/
State New
Headers show

Comments

Ian Taylor - Jan. 28, 2011, 12:01 a.m.
This libgo patch ensures that if we called opendir using an os.File, we
call closedir if we close the file.  This fixes
http://code.google.com/p/go/issues/detail?id=1448 .  Bootstrapped and
ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 0002fbcf1cf0 libgo/go/os/file_unix.go
--- a/libgo/go/os/file_unix.go	Thu Jan 27 15:27:40 2011 -0800
+++ b/libgo/go/os/file_unix.go	Thu Jan 27 15:59:07 2011 -0800
@@ -47,6 +47,13 @@ 
 	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