diff options
author | Russ Cox <rsc@golang.org> | 2010-04-05 23:36:52 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-04-05 23:36:52 -0700 |
commit | 899d4dcd31b80421367e31223f782db2208caea1 (patch) | |
tree | bc36994400b12ff733464c522eaea7ad05b574c3 | |
parent | a07561b4c0ff65ddda3976b2f8b9cb530095bd75 (diff) | |
download | golang-899d4dcd31b80421367e31223f782db2208caea1.tar.gz |
io/ioutil: fix bug in ReadFile when Open succeeds but Stat fails
R=gri
CC=golang-dev
http://codereview.appspot.com/867044
-rw-r--r-- | src/pkg/io/ioutil/ioutil.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pkg/io/ioutil/ioutil.go b/src/pkg/io/ioutil/ioutil.go index 65f457b24..ebdcf224f 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 |