Fix nuill pointer dereference

This commit is contained in:
Michael Boulton 2020-08-14 10:27:32 +01:00
parent c5985ee1a3
commit adfb859419
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 return StatusEntry{}, ErrInvalid
} }
ptr := C.git_status_byindex(statusList.ptr, C.size_t(index)) ptr := C.git_status_byindex(statusList.ptr, C.size_t(index))
if ptr == nil {
return StatusEntry{}, MakeGitError(C.int(ErrNotFound))
}
entry := statusEntryFromC(ptr) entry := statusEntryFromC(ptr)
runtime.KeepAlive(statusList) runtime.KeepAlive(statusList)