mirror of
https://git.proxmox.com/git/libgit2
synced 2025-10-18 17:13:37 +00:00
buffer: Do not put
anything if len is 0
This commit is contained in:
parent
6f4461763e
commit
92e0b67930
11
src/buffer.c
11
src/buffer.c
@ -176,10 +176,13 @@ int git_buf_putcn(git_buf *buf, char c, size_t len)
|
||||
|
||||
int git_buf_put(git_buf *buf, const char *data, size_t len)
|
||||
{
|
||||
ENSURE_SIZE(buf, buf->size + len + 1);
|
||||
memmove(buf->ptr + buf->size, data, len);
|
||||
buf->size += len;
|
||||
buf->ptr[buf->size] = '\0';
|
||||
if (len) {
|
||||
assert(data);
|
||||
ENSURE_SIZE(buf, buf->size + len + 1);
|
||||
memmove(buf->ptr + buf->size, data, len);
|
||||
buf->size += len;
|
||||
buf->ptr[buf->size] = '\0';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -281,11 +281,10 @@ check_buf_append_abc(
|
||||
/* more variations on append tests */
|
||||
void test_core_buffer__5(void)
|
||||
{
|
||||
check_buf_append("", "", "", 0, 8);
|
||||
check_buf_append("a", "", "a", 1, 8);
|
||||
check_buf_append("", "", "", 0, 0);
|
||||
check_buf_append("a", "", "a", 1, 0);
|
||||
check_buf_append("", "a", "a", 1, 8);
|
||||
check_buf_append("", "a", "a", 1, 8);
|
||||
check_buf_append("a", "", "a", 1, 8);
|
||||
check_buf_append("a", "b", "ab", 2, 8);
|
||||
check_buf_append("", "abcdefgh", "abcdefgh", 8, 16);
|
||||
check_buf_append("abcdefgh", "", "abcdefgh", 8, 16);
|
||||
|
Loading…
Reference in New Issue
Block a user