Commit 490e8a87 authored by Carlos Martín Nieto's avatar Carlos Martín Nieto Committed by GitHub

Merge pull request #368 from cbguder/master

Fix memory leak in Patch.String()
parents 89fc9e77 de521bb2
......@@ -40,15 +40,18 @@ func (patch *Patch) String() (string, error) {
if patch.ptr == nil {
return "", ErrInvalid
}
var buf C.git_buf
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var buf C.git_buf
ecode := C.git_patch_to_buf(&buf, patch.ptr)
if ecode < 0 {
return "", MakeGitError(ecode)
}
defer C.git_buf_free(&buf)
return C.GoString(buf.ptr), nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment