Skip to content

Commit

Permalink
Add a check to throw an error is a nil pointer is passed to unmarshal…
Browse files Browse the repository at this point in the history
…OrCopy (#5334)
  • Loading branch information
martinmr authored Apr 30, 2020
1 parent 56846ae commit 63a5e3a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions posting/mvcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ func (txn *Txn) CommitToDisk(writer *TxnWriter, commitTs uint64) error {
}

func unmarshalOrCopy(plist *pb.PostingList, item *badger.Item) error {
if plist == nil {
return errors.Errorf("cannot unmarshal value to a nil posting list of key %s",
hex.Dump(item.Key()))
}

return item.Value(func(val []byte) error {
if len(val) == 0 {
// empty pl
Expand Down

0 comments on commit 63a5e3a

Please sign in to comment.