Decode() may return nil when output length is 0 (patch attached)
- 主要语言
- Go
- 星标
- 0
- 派生
- 0
- PR 合并指标
- 30 天内没有已合并 PR
描述
```
If Decode() is called with a nil destination buffer and the uncompressed length
is zero, then a nil slice will be returned. This contradicts the docs, which
say that "a newly allocated slice will be returned" in this case.
Repro: http://play.golang.org/p/NiNH49J4M2 . This doesn't actually run because
the playground can't import snappy, but you can copy/paste this and run it on
your machine.
There are two alternatives for fixing this problem:
1. If the current behavior is "as designed", update the docs to say that a nil
slice will be returned of the decompressed output has length 0 and the dst
input is nil.
2. Add a nil check and allocate a zero-length byte slice to handle this case.
I've attached patches for each of these alternatives (but don't apply them both
since the two solutions are mutually exclusive).
```
Original issue reported on code.google.com by `Dave.Revell@gmail.com` on 28 Aug 2014 at 5:25
Attachments:
- [alloc_zero_length_return.diff](https://storage.googleapis.com/google-code-attachments/snappy-go/issue-6/comment-0/alloc_zero_length_return.diff)
- [doc_as_designed.diff](https://storage.googleapis.com/google-code-attachments/snappy-go/issue-6/comment-0/doc_as_designed.diff)
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。