summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFUJII Ryota <[email protected]>2015-12-16 16:37:50 +0900
committerFUJII Ryota <[email protected]>2015-12-16 16:43:26 +0900
commit1cdf1d70a2c08b1b87611be11cb448075ea45f2b (patch)
tree2a83e8b5b44ef5dcf17cca60232f8153168a43dc
parent749963ce55c6391bf7222057b037344a0cb837cf (diff)
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)
}