diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2022-02-17 01:43:18 +0000 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2022-02-17 15:00:32 +0000 |
commit | 8170260bb35f3761d2008405289832b2620abc53 (patch) | |
tree | 9eb372dc999bc14a92fbd8a78da5e7d2694a3ffe | |
parent | 308c1952aa55d63a1643dea798f5143eb41e8ed4 (diff) | |
download | rneovim-8170260bb35f3761d2008405289832b2620abc53.tar.gz rneovim-8170260bb35f3761d2008405289832b2620abc53.tar.bz2 rneovim-8170260bb35f3761d2008405289832b2620abc53.zip |
fix(ops): str_to_reg passing NULL to memcpy
Required for the tests introduced in v8.2.3601 to pass ASAN when running
test_alot.vim.
Co-authored-by: erw7 <erw7.github@gmail.com>
-rw-r--r-- | src/nvim/ops.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index ea480c0b31..95573799e5 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5696,7 +5696,9 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char_u *str // When appending, copy the previous line and free it after. size_t extra = append ? STRLEN(pp[--lnum]) : 0; char_u *s = xmallocz(line_len + extra); - memcpy(s, pp[lnum], extra); + if (extra > 0) { + memcpy(s, pp[lnum], extra); + } memcpy(s + extra, start, line_len); size_t s_len = extra + line_len; |