Skip to content

Commit

Permalink
issue#181 - nil check
Browse files Browse the repository at this point in the history
 - Added cast error capture and nil check to loadDocument()
  • Loading branch information
Leila Richardson-Noyes committed Feb 1, 2023
1 parent 67bd4f5 commit c77eed5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion redisearch/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func loadDocument(arr []interface{}, idIdx, scoreIdx, payloadIdx, fieldsIdx int)
}

if fieldsIdx > 0 {
lst := arr[idIdx+fieldsIdx].([]interface{})
lst, ok := arr[idIdx+fieldsIdx].([]interface{})
if !ok && arr[idIdx+fieldsIdx] == nil {
return doc, fmt.Errorf("document was nil")
}
doc.loadFields(lst)
}

Expand Down

0 comments on commit c77eed5

Please sign in to comment.