From 2626ae17df0581e023a014d457e0c9c438dbd127 Mon Sep 17 00:00:00 2001 From: Saurav Sen Date: Wed, 15 Apr 2020 10:50:09 -0700 Subject: [PATCH] Dont try to unmarshal if there is nothing to unmarshal --- bson/bson.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bson/bson.go b/bson/bson.go index 579aec13f..e2804b9bf 100644 --- a/bson/bson.go +++ b/bson/bson.go @@ -558,6 +558,9 @@ func Unmarshal(in []byte, out interface{}) (err error) { // See the Unmarshal function documentation for more details on the // unmarshalling process. func (raw Raw) Unmarshal(out interface{}) (err error) { + if len(raw.Data) == 0 { + return SetZero + } defer handleErr(&err) v := reflect.ValueOf(out) switch v.Kind() {