Commit 0085e354 authored by Russ Cox's avatar Russ Cox

io/ioutil: fix bug in ReadFile when Open succeeds but Stat fails

R=gri
CC=golang-dev
https://golang.org/cl/867044
parent 6d69fd1f
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment