Manually zero out buffer after reallocing it in rebase

This commit is contained in:
Michael Boulton 2020-08-14 16:10:48 +01:00
parent 0c942dbd89
commit a94318f919
No known key found for this signature in database
GPG Key ID: 8A62CA0BE2E0197E
2 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package git
/*
#include <git2.h>
extern void _go_git_buf_fill_null(git_buf *buf);
extern void _go_git_populate_commit_sign_cb(git_rebase_options *opts);
*/
import "C"
@ -102,6 +103,8 @@ func commitSignCallback(_signature *C.git_buf, _signature_field *C.git_buf, _com
return errors.New("could not grow buffer")
}
C._go_git_buf_fill_null(buf)
if int(C.git_buf_set(buf, cstr, clen)) != 0 {
return errors.New("could not set buffer")
}

View File

@ -6,6 +6,11 @@
typedef int (*gogit_submodule_cbk)(git_submodule *sm, const char *name, void *payload);
void _go_git_buf_fill_null(git_buf *buf)
{
memset(buf->ptr, '\0', buf->asize*sizeof(char));
}
void _go_git_populate_commit_sign_cb(git_rebase_options *opts)
{
opts->signing_cb = (git_commit_signing_cb)commitSignCallback;