mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
garray.c: Prevent ga_concat() using memcpy(NULL,...)
Calling ga_grow(gap, 0) does not reallocate memory for garray gap. Because of this, gap->ga_data can be NULL after such a call, if gap does not have memory allocated.
This commit is contained in:
@@ -184,11 +184,13 @@ char_u* ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET
|
||||
void ga_concat(garray_T *gap, const char_u *restrict s)
|
||||
{
|
||||
int len = (int)strlen((char *) s);
|
||||
if (len) {
|
||||
ga_grow(gap, len);
|
||||
char *data = gap->ga_data;
|
||||
memcpy(data + gap->ga_len, s, (size_t)len);
|
||||
gap->ga_len += len;
|
||||
}
|
||||
}
|
||||
|
||||
/// Append one byte to a growarray which contains bytes.
|
||||
///
|
||||
|
Reference in New Issue
Block a user