diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-23 15:41:58 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-24 23:49:10 +0200 |
| commit | caab22c0d468e90b6a95072f3092d5dcf331b3ef (patch) | |
| tree | 158e761b2c5fea6fc651e8960c84fbb9fe307094 /src/path.c | |
| parent | aacfd03dba68333da726bb63e2594f3ed4a16422 (diff) | |
| download | libgit2-caab22c0d468e90b6a95072f3092d5dcf331b3ef.tar.gz | |
buffer: don't allow growing borrowed buffers
When we don't own a buffer (asize=0) we currently allow the usage of
grow to copy the memory into a buffer we do own. This muddles the
meaning of grow, and lets us be a bit cavalier with ownership semantics.
Don't allow this any more. Usage of grow should be restricted to buffers
which we know own their own memory. If unsure, we must not attempt to
modify it.
Diffstat (limited to 'src/path.c')
| -rw-r--r-- | src/path.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/path.c b/src/path.c index c2c90e48d..2558058dd 100644 --- a/src/path.c +++ b/src/path.c @@ -640,7 +640,7 @@ static bool _check_dir_contents( /* leave base valid even if we could not make space for subdir */ if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, dir_size, sub_size) || GIT_ADD_SIZET_OVERFLOW(&alloc_size, alloc_size, 2) || - git_buf_try_grow(dir, alloc_size, false, false) < 0) + git_buf_try_grow(dir, alloc_size, false) < 0) return false; /* save excursion */ @@ -847,7 +847,7 @@ int git_path_make_relative(git_buf *path, const char *parent) /* save the offset as we might realllocate the pointer */ offset = p - path->ptr; - if (git_buf_try_grow(path, alloclen, 1, 0) < 0) + if (git_buf_try_grow(path, alloclen, 1) < 0) return -1; p = path->ptr + offset; |
