RediSearch / redisearch-go

Go client for RediSearch
https://redisearch.io
BSD 3-Clause "New" or "Revised" License
293 stars 65 forks source link

Prevent panic when lst (arr[idIdx+fieldsIdx]) is nil in loadDocument() #188

Open httpjamesm opened 11 months ago

httpjamesm commented 11 months ago

When using Search(), loadDocument is called where it loads fields and values through type casting. However, it doesn't do a nil check before casting arr[idIdx+fieldsIdx] into a []interface{}. Under specific circumstances without a comma ok check, the library will panic with the error panic: interface conversion: interface {} is nil, not []interface {}. This PR adds a comma ok check before casting lst to []interface{}.

sonarcloud[bot] commented 11 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information