mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-24 03:17:06 +00:00
buffer: make use of EINVALID for growing a borrowed buffer
This explains more closely what happens. While here, set an error message.
This commit is contained in:
parent
189aad45af
commit
a65992355d
@ -41,8 +41,10 @@ int git_buf_try_grow(
|
||||
if (buf->ptr == git_buf__oom)
|
||||
return -1;
|
||||
|
||||
if (buf->asize == 0 && buf->size != 0)
|
||||
return GIT_EINVALIDSPEC;
|
||||
if (buf->asize == 0 && buf->size != 0) {
|
||||
giterr_set(GITERR_INVALID, "cannot grow a borrowed buffer");
|
||||
return GIT_EINVALID;
|
||||
}
|
||||
|
||||
if (!target_size)
|
||||
target_size = buf->size;
|
||||
|
@ -1164,5 +1164,5 @@ void test_core_buffer__dont_grow_borrowed(void)
|
||||
cl_assert_equal_i(0, buf.asize);
|
||||
cl_assert_equal_i(strlen(somestring) + 1, buf.size);
|
||||
|
||||
cl_git_fail_with(GIT_EINVALIDSPEC, git_buf_grow(&buf, 1024));
|
||||
cl_git_fail_with(GIT_EINVALID, git_buf_grow(&buf, 1024));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user