aboutsummaryrefslogtreecommitdiffhomepage
path: root/builtin.cpp
diff options
context:
space:
mode:
authorGravatar Konrad Borowski <x.fix@o2.pl>2014-05-01 09:23:23 +0200
committerGravatar Konrad Borowski <x.fix@o2.pl>2014-05-01 09:23:23 +0200
commita7facfb760ff3169e8a1a49078b98199f541f910 (patch)
tree6bb48de382889714791899cbc8c14bc7218121e2 /builtin.cpp
parentf5e62f28bc7be454a173d3aedca136c7d514643a (diff)
Fix memory leak when displaying bind list.
This also removes duplication from the code.
Diffstat (limited to 'builtin.cpp')
-rw-r--r--builtin.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/builtin.cpp b/builtin.cpp
index 9f63e515..741dbd4a 100644
--- a/builtin.cpp
+++ b/builtin.cpp
@@ -425,27 +425,17 @@ static void builtin_bind_list(const wchar_t *bind_mode)
}
wcstring tname;
- if (input_terminfo_get_name(seq, tname))
- {
- append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", tname.c_str(), mode.c_str(), sets_mode.c_str());
- for (size_t i = 0; i < ecmds.size(); i++)
- {
- wcstring ecmd = ecmds.at(i);
- append_format(stdout_buffer, L" %ls", escape(ecmd.c_str(), 1));
- }
- append_format(stdout_buffer, L"\n");
- }
- else
+
+ const wcstring eseq = input_terminfo_get_name(seq, tname) ? tname : escape_string(seq, 1);
+ append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", eseq.c_str(), mode.c_str(), sets_mode.c_str());
+ for (size_t i = 0; i < ecmds.size(); i++)
{
- const wcstring eseq = escape_string(seq, 1);
- append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", eseq.c_str(), mode.c_str(), sets_mode.c_str());
- for (size_t i = 0; i < ecmds.size(); i++)
- {
- wcstring ecmd = ecmds.at(i);
- append_format(stdout_buffer, L" %ls", escape(ecmd.c_str(), 1));
- }
- append_format(stdout_buffer, L"\n");
+ wcstring ecmd = ecmds.at(i);
+ wchar_t *escaped = escape(ecmd.c_str(), 1);
+ append_format(stdout_buffer, L" %ls", escaped);
+ free(escaped);
}
+ append_format(stdout_buffer, L"\n");
}
}