0
0

Merge pull request #680 from steveyen/scorch

scorch docNumberToBytes() checks cap(buf) before allocating
This commit is contained in:
Steve Yen 2017-12-19 19:31:23 -08:00 committed by GitHub
commit 4d28b16896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -367,7 +367,11 @@ func (i *IndexSnapshot) TermFieldReader(term []byte, field string, includeFreq,
func docNumberToBytes(buf []byte, in uint64) []byte {
if len(buf) != 8 {
buf = make([]byte, 8)
if cap(buf) >= 8 {
buf = buf[0:8]
} else {
buf = make([]byte, 8)
}
}
binary.BigEndian.PutUint64(buf, in)
return buf