ソースを参照

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