Commit de521bb2 authored by Adam Berkovec's avatar Adam Berkovec Committed by Can Berk Güder

Fix memory leak in Patch.String()

Buffer allocated in Patch.String() was never freed
Signed-off-by: default avatarCan Berk Güder <cbguder@pivotal.io>
parent 4a142601
......@@ -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