Commit d29b9d5b authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

fix another memory corruption problem in display_string() found by

valgrind


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2598 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 6 additions and 3 deletions
+6 -3
...@@ -141,6 +141,9 @@ CVS code - ...@@ -141,6 +141,9 @@ CVS code -
do_statusbar_output() do_statusbar_output()
- Don't set answer_len until after it's been asserted that - Don't set answer_len until after it's been asserted that
answer isn't NULL. (DLR) answer isn't NULL. (DLR)
display_string()
- Avoid a memory corruption problem by allocating enough space
for len plus a trailing multibyte character and/or tab. (DLR)
nanogetstr() nanogetstr()
- Rename variable def to curranswer to avoid confusion. (DLR) - Rename variable def to curranswer to avoid confusion. (DLR)
- Only declare and use the tabbed variable if DISABLE_TABCOMP - Only declare and use the tabbed variable if DISABLE_TABCOMP
......
...@@ -2254,9 +2254,9 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool ...@@ -2254,9 +2254,9 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
assert(column <= start_col); assert(column <= start_col);
/* Allocate enough space for the entire line. It should contain /* Allocate enough space for the entire line, accounting for a
* (len + 2) multibyte characters at most. */ * trailing multibyte character and/or tab. */
alloc_len = mb_cur_max() * (len + 2); alloc_len = (mb_cur_max() * (len + 1)) + tabsize;
converted = charalloc(alloc_len + 1); converted = charalloc(alloc_len + 1);
index = 0; index = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment