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

Potential NPE in MimeTypeParameterList.hashCode()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 1.4.0
    • 1.3.0
    • client-libs
    • None
    • beta
    • generic
    • generic

      The following report was sent by email:


      Package java.awt.datatransfer
      Class MimeTypeParameterList
      Method hashCode
      File java\awt\datatransfer\MimeTypeParameterList.java, line 51

      public int hashCode() {
          int code = Integer.MAX_VALUE/45; // "random" value for empty lists
          String paramName = null;
          for (Enumeration enum = this.getNames();
              (enum.hasMoreElements()); paramName = (String)enum.nextElement()){
              code += paramName.hashCode();
              code += this.get(paramName).hashCode();
          }
           return code;
      } // hashCode()

      Expression
      paramName = (String)enum.nextElement()
      is executed only AFTER first loop iteration; on first iteration paramName is
      always null, therefore the next line
      code += paramName.hashCode();
      must cause NullPointer error.

            ehawkessunw Eric Hawkes (Inactive)
            ehawkessunw Eric Hawkes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: