浏览代码

Fix never succeeding read into empty buffer

The problem was that we set the capacity to one, but the length to zero,
which meant that `Read` could never put any data into the buffer,
returning zero, which meant that favicon thought there was no data.
Lucas Stadler 8 年之前
父节点
当前提交
26d2380974
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      go/favicon/favicon.go

+ 1 - 1
go/favicon/favicon.go

@ -247,7 +247,7 @@ func GetCanonicalFavicon(u string) (string, error) {
247 247
	if resp.StatusCode >= 400 || resp.Header.Get("Content-Length") == "0" {
248 248
		return "", errors.New("no /favicon.ico")
249 249
	}
250
	buf := make([]byte, 0, 1)
250
	buf := make([]byte, 1)
251 251
	n, err := resp.Body.Read(buf)
252 252
	if err != nil || n == 0 {
253 253
		return "", errors.New("can't read /favicon.ico")