Check whether a pointer is empty before accessing it to avoid SIGSEGV

This commit is contained in:
Haiyan Meng
2020-01-06 11:55:22 -08:00
parent 142c105500
commit 745b58b3d0

View File

@@ -309,9 +309,9 @@ func (idx *index) Exists(id string) (bool, error) {
op.WithPretty(),
)
if !res.IsError() {
if res != nil && !res.IsError() {
return true, nil
} else if res.StatusCode == 404 {
} else if res != nil && res.StatusCode == 404 {
return false, nil
} else {
return false, idx.responseErrorOrNil(