Fix null pointer dereference in getting status by index

This commit is contained in:
Michael Boulton 2020-08-14 10:56:14 +01:00
parent 462ebd83e0
commit 5b2c47f6b7
No known key found for this signature in database
GPG Key ID: 8A62CA0BE2E0197E
1 changed files with 3 additions and 0 deletions

View File

@ -86,6 +86,9 @@ func (statusList *StatusList) ByIndex(index int) (StatusEntry, error) {
return StatusEntry{}, ErrInvalid
}
ptr := C.git_status_byindex(statusList.ptr, C.size_t(index))
if ptr == nil {
return StatusEntry{}, MakeGitError(C.int(ErrNotFound))
}
entry := statusEntryFromC(ptr)
runtime.KeepAlive(statusList)