From: Russ Cox Date: Tue, 6 Apr 2010 06:36:52 +0000 (-0700) Subject: io/ioutil: fix bug in ReadFile when Open succeeds but Stat fails X-Git-Tag: weekly.2010-04-13~62 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0085e35498b7d4933d9bfb1a301c429b25d69847;p=gostls13.git io/ioutil: fix bug in ReadFile when Open succeeds but Stat fails R=gri CC=golang-dev https://golang.org/cl/867044 --- diff --git a/src/pkg/io/ioutil/ioutil.go b/src/pkg/io/ioutil/ioutil.go index 65f457b249..ebdcf224f7 100644 --- a/src/pkg/io/ioutil/ioutil.go +++ b/src/pkg/io/ioutil/ioutil.go @@ -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