Commit a6599235 by Carlos Martín Nieto

buffer: make use of EINVALID for growing a borrowed buffer

This explains more closely what happens. While here, set an error
message.
parent 189aad45
...@@ -41,8 +41,10 @@ int git_buf_try_grow( ...@@ -41,8 +41,10 @@ int git_buf_try_grow(
if (buf->ptr == git_buf__oom) if (buf->ptr == git_buf__oom)
return -1; return -1;
if (buf->asize == 0 && buf->size != 0) if (buf->asize == 0 && buf->size != 0) {
return GIT_EINVALIDSPEC; giterr_set(GITERR_INVALID, "cannot grow a borrowed buffer");
return GIT_EINVALID;
}
if (!target_size) if (!target_size)
target_size = buf->size; target_size = buf->size;
......
...@@ -1164,5 +1164,5 @@ void test_core_buffer__dont_grow_borrowed(void) ...@@ -1164,5 +1164,5 @@ void test_core_buffer__dont_grow_borrowed(void)
cl_assert_equal_i(0, buf.asize); cl_assert_equal_i(0, buf.asize);
cl_assert_equal_i(strlen(somestring) + 1, buf.size); 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));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment