Fix uneeded extra buf size increment in rebase

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

View File

@ -105,14 +105,10 @@ func commitSignCallback(_signature *C.git_buf, _signature_field *C.git_buf, _com
C._go_git_buf_fill_null(buf) 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") 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 return nil
} }