mirror of
https://github.com/golang/go
synced 2024-11-18 15:44:41 -07:00
io/ioutil: fix bug in ReadFile when Open succeeds but Stat fails
R=gri CC=golang-dev https://golang.org/cl/867044
This commit is contained in:
parent
6d69fd1fe3
commit
0085e35498
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user