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

partialArray is not created in javax.swing.text.html.parser.NPrintWriter.println(...) method

XMLWordPrintable

      See the feedback: http://mail.openjdk.java.net/pipermail/swing-dev/2016-September/006643.html
      -------------
      Hi,
      I found an error in javax.swing.text.html.parser.NPrintWriter.
      void javax.swing.text.html.parser.NPrintWriter.println(char[] array)

           public void println(char[] array) {
                if (this.numPrinted >= this.numLines) {
                      return;
                }
                char[] partialArray = null;
                for (int i = 0; i < array.length; i++) {
                      if (array[i] == '\n') {
                           this.numPrinted++;
                      }
                      if (this.numPrinted == this.numLines) {
      /* ==> */ partialArray = new char[i]; /* missing code, without there will be a NPE */
                           System.arraycopy(array, 0, partialArray, 0, i);
                      }
                }
                if (partialArray != null) {
                      super.print(partialArray);
                }
                if (this.numPrinted == this.numLines) {
                      return;
                }
                super.println(array);
                this.numPrinted++;
           }
      -------------

            psadhukhan Prasanta Sadhukhan
            alexsch Alexandr Scherbatiy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: