infinite mutual loop in FontMetrics causes Stack overflow

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 1.1
    • Component/s: client-libs
    • None
    • x86, sparc
    • solaris_2.5, windows_nt



      Name: mc57594 Date: 01/27/97


      getWidths calls charWidth, which calls getWidths, and back again until the stack is hammered.
      This is code from java.awt.FontMetrics.java v. 1.14: (comments mine)

          public int charWidth(char ch) { if (ch < 256) { return getWidths()[ch]; // YOW! } char data[] = {ch}; return charsWidth(data, 0, 1); }
          public int[] getWidths() { int widths[] = new int[256]; for (char ch = 0 ; ch < 256 ; ch++) { widths[ch] = charWidth(ch); // Whoops! } return widths; }
      ======================================================================

            Assignee:
            Jim Graham
            Reporter:
            Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: