From 899d4dcd31b80421367e31223f782db2208caea1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 5 Apr 2010 23:36:52 -0700 Subject: io/ioutil: fix bug in ReadFile when Open succeeds but Stat fails R=gri CC=golang-dev http://codereview.appspot.com/867044 --- src/pkg/io/ioutil/ioutil.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3