From 8170260bb35f3761d2008405289832b2620abc53 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 17 Feb 2022 01:43:18 +0000 Subject: 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 --- src/nvim/ops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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; -- cgit