summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-05-05 07:57:37 +1000
committerMaxime Coste <mawww@kakoune.org>2018-05-05 07:57:37 +1000
commitda1d78a3c2f20de6b43c88839627573cec2fda17 (patch)
tree72a6a070a5805c9491550aba951b05bb0f1787b0 /src
parent7325ad216cbecb0d14fdee40cef7cca3e39f8513 (diff)
Do not let exception propagate out of register restoring lambda
It is called during a std::vector destruction, which is noexcept, leading to terminate being called.
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc9
-rw-r--r--src/utils.hh2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 6907344b..089db654 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -1563,7 +1563,14 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
auto& register_manager = RegisterManager::instance();
auto make_register_restorer = [&](char c) {
return on_scope_end([&, c, save=register_manager[c].get(context) | gather<Vector<String>>()] {
- RegisterManager::instance()[c].set(context, save);
+ try
+ {
+ RegisterManager::instance()[c].set(context, save);
+ }
+ catch (runtime_error& err)
+ {
+ write_to_debug_buffer(format("failed to restore register '{}': {}", c, err.what()));
+ }
});
};
Vector<decltype(make_register_restorer(0))> saved_registers;
diff --git a/src/utils.hh b/src/utils.hh
index 23afdeb1..f21be9c1 100644
--- a/src/utils.hh
+++ b/src/utils.hh
@@ -73,7 +73,7 @@ public:
{ other.m_valid = false; }
[[gnu::always_inline]]
- ~OnScopeEnd() { if (m_valid) m_func(); }
+ ~OnScopeEnd() noexcept(noexcept(std::declval<T>()())) { if (m_valid) m_func(); }
private:
bool m_valid;