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

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

Expand Messages
  • Bram Moolenaar
    Aug 30, 2007
      Dominique Pelle wrote:

      > > How about this change instead:
      > >
      > > *** ../vim-7.1.094/src/message.c Tue Aug 7 21:59:26 2007
      > > --- src/message.c Thu Aug 30 21:05:17 2007
      > > ***************
      > > *** 1941,1946 ****
      > > --- 1942,1951 ----
      > > if (quit_more)
      > > return;
      > > }
      > > +
      > > + /* Quit when at the end of the text, avoid reading past it. */
      > > + if (maxlen >= 0 && (int)(s - str) >= maxlen)
      > > + break;
      > >
      >
      >
      > Indeed, I overlooked the fact that maxlen could be negative.
      >
      > Shouldn't the test be:
      >
      > /* Quit when at the end of the text, avoid reading past it. */
      > if ((maxlen >= 0 && (int)(s - str) >= maxlen) || *s == NUL)
      > break;
      >
      > Which is the negation of the test in the while loop at line 1845.

      OK.

      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;
      }



      --
      ARTHUR: Right! Knights! Forward!
      ARTHUR leads a charge toward the castle. Various shots of them battling on,
      despite being hit by a variety of farm animals.
      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      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