From 8299d1da1f4e3fd856dc81ff1c8ec584714582e0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 1 Nov 2021 09:05:57 +1100 Subject: [PATCH] Fix pasting all from empty register Raise an error if the register is empty for paste-all Fixes #4414 --- src/normal.cc | 3 +++ test/regression/4414-crash-on-paste-all/cmd | 1 + test/regression/4414-crash-on-paste-all/in | 1 + test/regression/4414-crash-on-paste-all/out | 1 + 4 files changed, 6 insertions(+) create mode 100644 test/regression/4414-crash-on-paste-all/cmd create mode 100644 test/regression/4414-crash-on-paste-all/in create mode 100644 test/regression/4414-crash-on-paste-all/out diff --git a/src/normal.cc b/src/normal.cc index 64daabc6..8d2ed82c 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -720,6 +720,9 @@ void paste_all(Context& context, NormalParams params) offsets.push_back(all.length()); } + if (offsets.empty()) + throw runtime_error("nothing to paste"); + Buffer& buffer = context.buffer(); Vector result; auto& selections = context.selections(); diff --git a/test/regression/4414-crash-on-paste-all/cmd b/test/regression/4414-crash-on-paste-all/cmd new file mode 100644 index 00000000..a857f648 --- /dev/null +++ b/test/regression/4414-crash-on-paste-all/cmd @@ -0,0 +1 @@ + diff --git a/test/regression/4414-crash-on-paste-all/in b/test/regression/4414-crash-on-paste-all/in new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/4414-crash-on-paste-all/in @@ -0,0 +1 @@ + diff --git a/test/regression/4414-crash-on-paste-all/out b/test/regression/4414-crash-on-paste-all/out new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/4414-crash-on-paste-all/out @@ -0,0 +1 @@ +