Fix Fetch/Push memory allocation problems #271
16
remote.go
16
remote.go
|
@ -623,14 +623,16 @@ func (o *Remote) Fetch(refspecs []string, opts *FetchOptions, msg string) error
|
||||||
crefspecs.strings = makeCStringsFromStrings(refspecs)
|
crefspecs.strings = makeCStringsFromStrings(refspecs)
|
||||||
defer freeStrarray(&crefspecs)
|
defer freeStrarray(&crefspecs)
|
||||||
|
|
||||||
var coptions C.git_fetch_options
|
coptions := (*C.git_fetch_options)(C.calloc(1, C.size_t(unsafe.Sizeof(C.git_fetch_options{}))))
|
||||||
populateFetchOptions(&coptions, opts);
|
defer C.free(unsafe.Pointer(coptions))
|
||||||
|
|
||||||
|
populateFetchOptions(coptions, opts)
|
||||||
defer untrackCalbacksPayload(&coptions.callbacks)
|
defer untrackCalbacksPayload(&coptions.callbacks)
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_remote_fetch(o.ptr, &crefspecs, &coptions, cmsg)
|
ret := C.git_remote_fetch(o.ptr, &crefspecs, coptions, cmsg)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return MakeGitError(ret)
|
return MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
@ -710,14 +712,16 @@ func (o *Remote) Push(refspecs []string, opts *PushOptions) error {
|
||||||
crefspecs.strings = makeCStringsFromStrings(refspecs)
|
crefspecs.strings = makeCStringsFromStrings(refspecs)
|
||||||
defer freeStrarray(&crefspecs)
|
defer freeStrarray(&crefspecs)
|
||||||
|
|
||||||
var coptions C.git_push_options
|
coptions := (*C.git_push_options)(C.calloc(1, C.size_t(unsafe.Sizeof(C.git_push_options{}))))
|
||||||
populatePushOptions(&coptions, opts)
|
defer C.free(unsafe.Pointer(coptions))
|
||||||
|
|
||||||
|
populatePushOptions(coptions, opts)
|
||||||
defer untrackCalbacksPayload(&coptions.callbacks)
|
defer untrackCalbacksPayload(&coptions.callbacks)
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_remote_push(o.ptr, &crefspecs, &coptions)
|
ret := C.git_remote_push(o.ptr, &crefspecs, coptions)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return MakeGitError(ret)
|
return MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue