andrew-d / andrew-d/snappy-go

Decode() may return nil when output length is 0 (patch attached)

Aberta
#6 0 comentários 0 reações 0 responsáveis Ver no GitHub
auto-migrated Priority-Medium Type-Defect
Linguagem predominante
Go
Estrelas
0
Forks
0
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

```
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)

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.