Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6473239

Off-by-one bug in tab computation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P4
    • None
    • 6
    • tools
    • generic
    • generic

    Description

      LineTabMapImpl.getPosition() in b99 is implmented as follows:

      public int getPosition(int line, int column) {
      int pos = startPosition[line - FIRSTLINE];
      column -= FIRSTCOLUMN;
      int col = 0;
      while (col < column) {
      pos++;
      if (tabMap.get(pos))
      col = (col / TabInc * TabInc) + TabInc;
      else
      col++;
      }
      return pos;
      }

      but it should be:

      public int getPosition(int line, int column) {
      int pos = startPosition[line - FIRSTLINE];
      column -= FIRSTCOLUMN;
      int col = 0;
      while (col < column) {
      if (tabMap.get(pos++))
      col = (col / TabInc * TabInc) + TabInc;
      else
      col++;
      }
      return pos;
      }

      notice that the current code invokes tabMap.get() with a wrong index.

      Attachments

        Activity

          People

            jjg Jonathan Gibbons
            kkawagucsunw Kohsuke Kawaguchi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: