summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-12-16 15:19:35 +0100
committerCarlos Martín Nieto <[email protected]>2015-12-16 15:19:35 +0100
commit9022ab9c195e646f9e9928b4ab3f2e83c8f04268 (patch)
tree2a83e8b5b44ef5dcf17cca60232f8153168a43dc
parent749963ce55c6391bf7222057b037344a0cb837cf (diff)
parent1cdf1d70a2c08b1b87611be11cb448075ea45f2b (diff)
Merge pull request #273 from clearr/fix-index-entrybypath-leak
Fix a memory leak in Index.EntryByPath()
-rw-r--r--index.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/index.go b/index.go
index 1875e32..8417b65 100644
--- a/index.go
+++ b/index.go
@@ -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)
}