diff options
author | Kevin Ballard <kevin@sb.org> | 2014-09-25 18:20:03 -0700 |
---|---|---|
committer | Kevin Ballard <kevin@sb.org> | 2014-09-25 18:20:03 -0700 |
commit | 35595dbffdf413694b31da46129432ef345921af (patch) | |
tree | e78b379cf7854b1a8402f8da267e8f6d84450c6f /reader.cpp | |
parent | cd4fa518b86ddfb3e946fa4dd69e9e32a58ef81e (diff) |
Make escape() return a wcstring
This avoids the potential for leaking the resulting string.
Diffstat (limited to 'reader.cpp')
-rw-r--r-- | reader.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -1309,7 +1309,6 @@ wcstring completion_apply_to_command_line(const wcstring &val_str, complete_flag { size_t move_cursor; const wchar_t *begin, *end; - wchar_t *escaped; const wchar_t *buff = command_line.c_str(); parse_util_token_extent(buff, cursor_pos, &begin, 0, 0, 0); @@ -1321,10 +1320,9 @@ wcstring completion_apply_to_command_line(const wcstring &val_str, complete_flag { /* Respect COMPLETE_DONT_ESCAPE_TILDES */ bool no_tilde = !!(flags & COMPLETE_DONT_ESCAPE_TILDES); - escaped = escape(val, ESCAPE_ALL | ESCAPE_NO_QUOTED | (no_tilde ? ESCAPE_NO_TILDE : 0)); + wcstring escaped = escape(val, ESCAPE_ALL | ESCAPE_NO_QUOTED | (no_tilde ? ESCAPE_NO_TILDE : 0)); sb.append(escaped); - move_cursor = wcslen(escaped); - free(escaped); + move_cursor = escaped.size(); } else { |