Skip to content

Commit

Permalink
[BP] Error handling for empty vellum data (#150)
Browse files Browse the repository at this point in the history
* address potential empty slice panic
  • Loading branch information
Thejas-bhat authored and abhinavdangeti committed May 16, 2023
1 parent 0ebf4e2 commit edc21be
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ func (sb *SegmentBase) dictionary(field string) (rv *Dictionary, err error) {
if rv.fst, ok = sb.fieldFSTs[rv.fieldID]; !ok {
// read the length of the vellum data
vellumLen, read := binary.Uvarint(sb.mem[dictStart : dictStart+binary.MaxVarintLen64])
if vellumLen == 0 {
sb.m.Unlock()
return nil, fmt.Errorf("empty dictionary for field: %v", field)
}
fstBytes := sb.mem[dictStart+uint64(read) : dictStart+uint64(read)+vellumLen]
rv.fst, err = vellum.Load(fstBytes)
if err != nil {
Expand Down

0 comments on commit edc21be

Please sign in to comment.