]> Cypherpunks repositories - gostls13.git/commitdiff
io/ioutil: fix bug in ReadFile when Open succeeds but Stat fails
authorRuss Cox <rsc@golang.org>
Tue, 6 Apr 2010 06:36:52 +0000 (23:36 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 6 Apr 2010 06:36:52 +0000 (23:36 -0700)
R=gri
CC=golang-dev
https://golang.org/cl/867044

src/pkg/io/ioutil/ioutil.go

index 65f457b249634071381eae428b3fd475468c8888..ebdcf224f75aa7b440f0875d2cb598e8491d1e71 100644 (file)
@@ -31,7 +31,7 @@ func ReadFile(filename string) ([]byte, os.Error) {
        // read, so let's try it but be prepared for the answer to be wrong.
        dir, err := f.Stat()
        var n uint64
-       if err != nil && dir.Size < 2e9 { // Don't preallocate a huge buffer, just in case.
+       if err == nil && dir.Size < 2e9 { // Don't preallocate a huge buffer, just in case.
                n = dir.Size
        }
        // Add a little extra in case Size is zero, and to avoid another allocation after