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(), op.WithPretty(),
) )
if !res.IsError() { if res != nil && !res.IsError() {
return true, nil return true, nil
} else if res.StatusCode == 404 { } else if res != nil && res.StatusCode == 404 {
return false, nil return false, nil
} else { } else {
return false, idx.responseErrorOrNil( return false, idx.responseErrorOrNil(