Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1080

XSAttributeUseImpl.getConstraintValue() might cause NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.6.2
    • 2.9.1
    • None
    • None
    • Xerces2-J CVS HEAD (May 12, 2005)

    Description

      In case of error "a-props-correct.2" (Invalid value constraint value '%1' in attribute '%2'.), attribute fDefault or fDefault.actualValue might be null and the code might result in a NPE.

      How to reproduce: Example from xml schema test suite:
      msxsdtest\attribute\attP006.xsd

      In my case, when anlysing invalid schema files (as good as possible), it is important not to have this exception, so I'm working with my own patched version of Xerces2-J. It would be nice if you would fix this somewhen.

      My fix is quite simple: just check on null:

      Old:
      return getConstraintType() == XSConstants.VC_NONE ?
      null :
      fDefault.actualValue.toString();

      New:
      return getConstraintType() == XSConstants.VC_NONE ? null :
      (fDefault == null ? null :
      (fDefault.actualValue == null ? null :
      (fDefault.actualValue.toString())));

      Attachments

        1. attP006.xsd
          0.7 kB

        Activity

          People

            mrglavas@ca.ibm.com Michael Glavassevich
            kriede Kurt Riede
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: