diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-10-15 23:33:43 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-10-15 23:33:43 +0300 |
commit | d556aee67e615b48c25861741d28d103109235e3 (patch) | |
tree | 46c30b4c420c1f50cdc8b4e10a1e13e440eb1c01 /src/core-commands.c | |
parent | 7413b9cab2690f7bed6d82e903b0fc08b1590360 (diff) | |
download | sciteco-d556aee67e615b48c25861741d28d103109235e3.tar.gz |
fixed memory corruptions due to undoing the teco_machine_stringbuilding_t::codepage
* It's contained in teco_machine_main_t which is created per macro call frame.
So after macro calls, the machine no longer exists.
It is therefore unsafe to undo its members indiscriminately.
* On the other hand, we must undo the codepage setting when run interactively,
so it is now only undone when belonging to the commandline macro frame.
* This was actually causing memory corruptions on every fnkeys cursor movement, but never
caused crashes - probably because the invalid pointers are always pointing to unused
parts of the C call stack.
* Initially broken in b31b8871.
Diffstat (limited to 'src/core-commands.c')
-rw-r--r-- | src/core-commands.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index a390fa4..befb6e8 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -2759,8 +2759,12 @@ teco_state_insert_initial(teco_machine_main_t *ctx, GError **error) /* * Current document's encoding determines the behaviour of * string building constructs. + * + * NOTE: This is not safe to undo in macro calls. */ - teco_undo_guint(ctx->expectstring.machine.codepage) = teco_interface_get_codepage(); + if (ctx == &teco_cmdline.machine) + teco_undo_guint(ctx->expectstring.machine.codepage); + ctx->expectstring.machine.codepage = teco_interface_get_codepage(); if (!teco_expressions_eval(FALSE, error)) return FALSE; |