summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2014-11-21 13:31:30 +0100
committerVicent Marti <tanoku@gmail.com>2014-11-21 17:21:33 +0100
commit92e0b67930f350a40575954f4638cbc71fee57d2 (patch)
tree5bd1f15f080785ee86f7c6fc4fca55d5336d6b0d /src/buffer.c
parent6f4461763eb0518112d22c3a096417e7eedf7385 (diff)
downloadlibgit2-92e0b67930f350a40575954f4638cbc71fee57d2.tar.gz
buffer: Do not `put` anything if len is 0
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/buffer.c b/src/buffer.c
index e9c420e16..7744d8f49 100644
--- a/src/buffer.c
+++ b/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;
}