{"action":"opened","issue":{"url":"https://api.github.com/repos/valyala/fasthttp/issues/193","repository_url":"https://api.github.com/repos/valyala/fasthttp","labels_url":"https://api.github.com/repos/valyala/fasthttp/issues/193/labels{/name}","comments_url":"https://api.github.com/repos/valyala/fasthttp/issues/193/comments","events_url":"https://api.github.com/repos/valyala/fasthttp/issues/193/events","html_url":"https://github.com/valyala/fasthttp/issues/193","id":184395256,"number":193,"title":"gzipBody() maybe have a bug ","user":{"login":"barnettZQG","id":18493394,"avatar_url":"https://avatars.githubusercontent.com/u/18493394?v=3","gravatar_id":"","url":"https://api.github.com/users/barnettZQG","html_url":"https://github.com/barnettZQG","followers_url":"https://api.github.com/users/barnettZQG/followers","following_url":"https://api.github.com/users/barnettZQG/following{/other_user}","gists_url":"https://api.github.com/users/barnettZQG/gists{/gist_id}","starred_url":"https://api.github.com/users/barnettZQG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barnettZQG/subscriptions","organizations_url":"https://api.github.com/users/barnettZQG/orgs","repos_url":"https://api.github.com/users/barnettZQG/repos","events_url":"https://api.github.com/users/barnettZQG/events{/privacy}","received_events_url":"https://api.github.com/users/barnettZQG/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-21T04:07:46Z","updated_at":"2016-10-21T04:07:46Z","closed_at":null,"body":"if a response.body is nil.\r\nin method  gzipBody() \r\n```\r\n// Hack: swap resp.body with w.\r\nresponseBodyPool.Put(resp.body)\r\nresp.body = w\r\n```\r\nmethod Put() will happen nil pointer dereference.so it maybe write:\r\n```\r\nif resp.bodyStream != nil {\r\n\t\tbs := resp.bodyStream\r\n\t\tresp.bodyStream = NewStreamReader(func(sw *bufio.Writer) {\r\n\t\t\tzw := acquireGzipWriter(sw, level)\r\n\t\t\tfw := &flushWriter{\r\n\t\t\t\twf: zw,\r\n\t\t\t\tbw: sw,\r\n\t\t\t}\r\n\t\t\tcopyZeroAlloc(fw, bs)\r\n\t\t\treleaseGzipWriter(zw)\r\n\t\t\tif bsc, ok := bs.(io.Closer); ok {\r\n\t\t\t\tbsc.Close()\r\n\t\t\t}\r\n\t\t})\r\n\t} else if resp.body!=nil {\r\n\t\tw := responseBodyPool.Get()\r\n\t\tzw := acquireGzipWriter(w, level)\r\n\t\t_, err := zw.Write(resp.bodyBytes())\r\n\t\treleaseGzipWriter(zw)\r\n\t\tif err != nil {\r\n\t\t\treturn err\r\n\t\t}\r\n\r\n\t\t// Hack: swap resp.body with w.\r\n\t\tresponseBodyPool.Put(resp.body)\r\n\t\tresp.body = w\r\n\t}\r\n``` "}}
{"actor":{"display_login":"barnettZQG"}}