Fix a memory leak in Index.EntryByPath() #273

Merged
ryot4 merged 1 commits from fix-index-entrybypath-leak into next 2015-12-16 08:19:35 -06:00
1 changed files with 4 additions and 1 deletions

View File

@ -350,10 +350,13 @@ func (v *Index) EntryByIndex(index uint) (*IndexEntry, error) {
}
func (v *Index) EntryByPath(path string, stage int) (*IndexEntry, error) {
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
runtime.LockOSThread()
defer runtime.UnlockOSThread()
centry := C.git_index_get_bypath(v.ptr, C.CString(path), C.int(stage))
centry := C.git_index_get_bypath(v.ptr, cpath, C.int(stage))
if centry == nil {
return nil, MakeGitError(C.GIT_ENOTFOUND)
}