Loading ...
Sorry, an error occurred while loading the content.

47578Re: Patch to fix read out of bound when resizing terminal

Expand Messages
  • Dominique Pelle
    Aug 30, 2007
    • 0 Attachment
      On 8/30/07, Bram Moolenaar <Bram@...> wrote:

      > Hmm, perhaps the best way is to keep a flag that we changed the "s"
      > pointer, and then do "continue". I think that is what was originally
      > intended. It's also simpler and more straightforward. Can you check
      > that the valgrind error doesn't happen then?
      >
      >
      > *** ../vim-7.1.094/src/message.c Tue Aug 7 21:59:26 2007
      > --- src/message.c Thu Aug 30 22:53:03 2007
      > ***************
      > *** 1840,1845 ****
      > --- 1841,1847 ----
      > char_u *sb_str = str;
      > int sb_col = msg_col;
      > int wrap;
      > + int did_last_char;
      >
      > did_wait_return = FALSE;
      > while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
      > ***************
      > *** 1909,1915 ****
      > --- 1911,1920 ----
      > else
      > #endif
      > msg_screen_putchar(*s++, attr);
      > + did_last_char = TRUE;
      > }
      > + else
      > + did_last_char = FALSE;
      >
      > if (p_more)
      > /* store text for scrolling back */
      > ***************
      > *** 1944,1954 ****
      >
      > /* When we displayed a char in last column need to check if there
      > * is still more. */
      > ! if (*s >= ' '
      > ! #ifdef FEAT_RIGHTLEFT
      > ! && !cmdmsg_rl
      > ! #endif
      > ! )
      > continue;
      > }
      >
      > --- 1949,1955 ----
      >
      > /* When we displayed a char in last column need to check if there
      > * is still more. */
      > ! if (did_last_char)
      > continue;
      > }


      Yes, that fixes it as well: valgrind no longer complains about
      accessing string beyond the end when I resize the terminal.

      There are 2 other odd things I observe though when resizing
      the terminal (before and after the patch so it's unrelated to
      this patch):

      1/ when Ex command is longer than the terminal, ex command
      wraps it (good) but when the terminal becomes very narrow,
      the Ex command is displayed in a odd way with spaces in
      the middle.

      For example, with ex command ":012345678901234567890",
      when the terminal is narrow, it wraps as follows (good):

      :012345678901234
      567890

      But if terminal is resized even narrower, something odd begins
      to happen (which does not look expected). I observe something
      like this for example:

      :01234567
      89 0
      123456789
      0

      The spaces in the middle don't look expected.


      2/ If my cursor is at the end of the ex command, resizing the
      terminal may move the cursor to somewhere in the middle of
      the Ex command. I don't think that's expected either.

      Those 2 issues are admittedly nitpicking, but they may
      indicate a bug which may possibly have other consequences.

      -- Dominique

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 12 messages in this topic