From b7b98405089e69dfae0fc11e2a423860f50756e9 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 18 Sep 2024 12:32:16 +0200 Subject: check that local register is not edited at the end of macro calls * This was unsafe and could easily result in crashes, since teco_qreg_current would afterwards point to an already freed Q-Register. * Since automatically editing another register or buffer is not easy to do right, we throw an error instead. --- src/qreg-commands.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/qreg-commands.c') diff --git a/src/qreg-commands.c b/src/qreg-commands.c index 8d28e7d..a96eb5f 100644 --- a/src/qreg-commands.c +++ b/src/qreg-commands.c @@ -652,8 +652,15 @@ teco_state_macro_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg, } else { g_auto(teco_qreg_table_t) table; teco_qreg_table_init(&table, FALSE); + if (!teco_qreg_execute(qreg, &table, error)) return NULL; + if (teco_qreg_current && !teco_qreg_current->must_undo) { + /* currently editing local Q-Register */ + teco_error_editinglocalqreg_set(error, teco_qreg_current->head.name.data, + teco_qreg_current->head.name.len); + return NULL; + } } return &teco_state_start; -- cgit v1.2.3