Fix use after free in enter_user_mode, use user.<name> for modename

Fixes #3192
This commit is contained in:
Maxime Coste 2019-11-12 08:54:49 +11:00
parent b464822f1b
commit 6eb820dc54

View File

@ -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;