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

Re: [patch] fixed valgrind error in after_pathsep()

Expand Messages
  • Bram Moolenaar
    ... [...] ... Thanks, I ll include it soon. -- Marriage is when a man and woman become as one; the trouble starts when they try to decide which one /// Bram
    Message 1 of 2 , Jul 3, 2011
    • 0 Attachment
      Dominique Pelle wrote:

      > I can reproduce the following Valgrind error with Vim-7.3.237:
      [...]
      >
      > Steps to reproduce:
      >
      > - install the vcscommand plugin:
      > http://www.vim.org/scripts/script.php?script_id=90
      >
      > - run:
      > $ vim -c VCSVimDiff
      >
      > Running VCSVimDiff on an unnamed buffer does not make much sense
      > but it should not cause vim to access invalid memory.
      >
      > Code in misc2.c:
      >
      > 3219 /*
      > 3220 * Return TRUE if "p" points to just after a path separator.
      > 3221 * Take care of multi-byte characters.
      > 3222 * "b" must point to the start of the file name
      > 3223 */
      > 3224 int
      > 3225 after_pathsep(b, p)
      > 3226 char_u *b;
      > 3227 char_u *p;
      > 3228 {
      > 3229 return vim_ispathsep(p[-1])
      > 3230 && (!has_mbyte || (*mb_head_off)(b,
      > p - 1) == 0);
      > 3231 }
      >
      > When error happens, b and p are identical, they point to the beginning
      > of an empty string. So p[-1] at misc2.c:3229 is an invalid read of 1 byte
      > and return value of after_pathsep() is then undefined.
      >
      > Attached patch fixes it.

      Thanks, I'll include it soon.

      --
      "Marriage is when a man and woman become as one; the trouble starts
      when they try to decide which one"

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.