From bb9dcc7be4f46afd51a8e5f78f9523b1a6175bf6 Mon Sep 17 00:00:00 2001 From: Michael Boulton Date: Fri, 14 Aug 2020 16:14:15 +0100 Subject: [PATCH] Fix uneeded extra buf size increment in rebase --- rebase.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rebase.go b/rebase.go index 881c836..5cc8d73 100644 --- a/rebase.go +++ b/rebase.go @@ -105,14 +105,10 @@ func commitSignCallback(_signature *C.git_buf, _signature_field *C.git_buf, _com C._go_git_buf_fill_null(buf) - if int(C.git_buf_set(buf, cstr, clen)) != 0 { + if int(C.git_buf_set(buf, cstr, clen+1)) != 0 { return errors.New("could not set buffer") } - // git_buf_set sets 'size' to the 'size' of the buffer to 'clen', but we want it to be clen+1 because after returning it asserts that the buffer ends with a null byte, which Go strings don't - // This avoids having to convert the string to a []byte, then adding a null byte, then doing another copy - buf.size += 1 - return nil }