diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-10-15 20:02:50 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-10-15 20:02:50 +0300 |
commit | 7413b9cab2690f7bed6d82e903b0fc08b1590360 (patch) | |
tree | 975fa715fbd211e4e4d7b8c1ba5429f3c510992c /src | |
parent | 95dca302011d49e465a1ee50f722684969e49781 (diff) | |
download | sciteco-7413b9cab2690f7bed6d82e903b0fc08b1590360.tar.gz |
fixed memory leak when replacing command lines
* this would also leak a few bytes on every of fnkeys.tes' movement commands
Diffstat (limited to 'src')
-rw-r--r-- | src/cmdline.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/cmdline.c b/src/cmdline.c index 232fb19..816816c 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -86,7 +86,7 @@ static gboolean teco_cmdline_insert(const gchar *data, gsize len, GError **error) { const teco_string_t src = {(gchar *)data, len}; - teco_string_t old_cmdline = {NULL, 0}; + g_auto(teco_string_t) old_cmdline = {NULL, 0}; gsize repl_pc = 0; teco_cmdline.machine.macro_pc = teco_cmdline.pc = teco_cmdline.effective_len; @@ -110,8 +110,6 @@ teco_cmdline_insert(const gchar *data, gsize len, GError **error) /* * Parse/execute characters, one at a time so * undo tokens get emitted for the corresponding characters. - * - * FIXME: The inner loop should be factored out. */ while (teco_cmdline.pc < teco_cmdline.effective_len) { g_autoptr(GError) tmp_error = NULL; @@ -162,6 +160,7 @@ teco_cmdline_insert(const gchar *data, gsize len, GError **error) teco_string_clear(&teco_cmdline.str); teco_cmdline.str = old_cmdline; + memset(&old_cmdline, 0, sizeof(old_cmdline)); teco_cmdline.machine.macro_pc = teco_cmdline.pc = repl_pc; /* rubout cmdline replacement command */ |