From 6eb820dc54c96100909a179f2a58bbb9b00b51cd Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 12 Nov 2019 08:54:49 +1100 Subject: [PATCH] Fix use after free in enter_user_mode, use `user.` for modename Fixes #3192 --- src/commands.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 9dac21a5..53257096 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -2413,9 +2413,10 @@ const CommandDesc declare_user_mode_cmd = { } }; -void enter_user_mode(Context& context, StringView mode_name, KeymapMode mode, bool lock) +// We need ownership of the mode_name in the lock case +void enter_user_mode(Context& context, String mode_name, KeymapMode mode, bool lock) { - on_next_key_with_autoinfo(context, format("user:{}", mode_name), KeymapMode::None, + on_next_key_with_autoinfo(context, format("user.{}", mode_name), KeymapMode::None, [mode_name, mode, lock](Key key, Context& context) mutable { if (key == Key::Escape) return;