0
0
Fork 0

extra protection if dict address is 0 (empty segment)

This commit is contained in:
Marty Schoch 2017-12-13 13:31:18 -05:00
parent a681314740
commit c15c3c11cd
1 changed files with 12 additions and 10 deletions

View File

@ -150,16 +150,18 @@ func (s *Segment) dictionary(field string) (*Dictionary, error) {
dictStart := s.fieldsOffsets[rv.fieldID]
// read the length of the vellum data
vellumLen, read := binary.Uvarint(s.mm[dictStart : dictStart+binary.MaxVarintLen64])
fstBytes := s.mm[dictStart+uint64(read) : dictStart+uint64(read)+vellumLen]
if fstBytes != nil {
fst, err := vellum.Load(fstBytes)
if err != nil {
return nil, fmt.Errorf("dictionary field %s vellum err: %v", field, err)
}
if err == nil {
rv.fst = fst
if dictStart > 0 {
// read the length of the vellum data
vellumLen, read := binary.Uvarint(s.mm[dictStart : dictStart+binary.MaxVarintLen64])
fstBytes := s.mm[dictStart+uint64(read) : dictStart+uint64(read)+vellumLen]
if fstBytes != nil {
fst, err := vellum.Load(fstBytes)
if err != nil {
return nil, fmt.Errorf("dictionary field %s vellum err: %v", field, err)
}
if err == nil {
rv.fst = fst
}
}
}