Merge pull request #273 from clearr/fix-index-entrybypath-leak

Fix a memory leak in Index.EntryByPath()
This commit is contained in:
Carlos Martín Nieto 2015-12-16 15:19:35 +01:00
commit 9022ab9c19
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)
}