Fix null pointer dereference in status.ByIndex #628

Merged
mbfr merged 7 commits from fix-status-nullptr into master 2020-08-14 13:19:21 -05:00
1 changed files with 1 additions and 3 deletions
Showing only changes of commit faa4e293ba - Show all commits

View File

@ -87,9 +87,7 @@ func (statusList *StatusList) ByIndex(index int) (StatusEntry, error) {
} }
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 { if ptr == nil {
runtime.LockOSThread() return StatusEntry{}, fmt.Errorf("Index out of Bounds")
defer runtime.UnlockOSThread()
return StatusEntry{}, MakeGitError(C.int(ErrNotFound))
} }
entry := statusEntryFromC(ptr) entry := statusEntryFromC(ptr)
runtime.KeepAlive(statusList) runtime.KeepAlive(statusList)