Xerces2-J
  1. Xerces2-J
  2. XERCESJ-1555

An incomplete fix for the NPE bugs in AbstractDOMParser.java

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Other

      Description

      The fix revision 318356 was aimed to remove an NPE bug on the "this.locator" in the method "startDocument" of the file "/xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java" , but it is incomplete.
      Since the "this.locator" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods.

      The buggy code locations the same fix needs to be applied at are as bellows:

      Lines 626 and 673 of the method "startDocument":

      public void startDocument(XMLLocator locator, String encoding, Augmentations augs)
      throws XNIException {

      fInDocument = true;
      if (!fDeferNodeExpansion) {
      if (fDocumentClassName.equals(DEFAULT_DOCUMENT_CLASS_NAME))

      { fDocument = new DocumentImpl(); fDocumentImpl = (CoreDocumentImpl)fDocument; // REVISIT: when DOM Level 3 is REC rely on Document.support // instead of specific class // set DOM error checking off fDocumentImpl.setStrictErrorChecking(false); // set actual encoding fDocumentImpl.setActualEncoding(encoding); // set documentURI fDocumentImpl.setDocumentURI(locator.getExpandedSystemId()); }

      else {
      // use specified document class
      try {
      Class documentClass = Class.forName(fDocumentClassName);
      fDocument = (Document)documentClass.newInstance();

      // if subclass of our own class that's cool too
      Class defaultDocClass =
      Class.forName(CORE_DOCUMENT_CLASS_NAME);
      if (defaultDocClass.isAssignableFrom(documentClass)) {
      fDocumentImpl = (CoreDocumentImpl)fDocument;
      // REVISIT: when DOM Level 3 is REC rely on
      // Document.support instead of specific class
      // set DOM error checking off
      fDocumentImpl.setStrictErrorChecking(false);
      // set actual encoding
      fDocumentImpl.setActualEncoding(encoding);
      // set documentURI
      if (locator != null)

      { fDocumentImpl.setDocumentURI(locator.getExpandedSystemId()); }

      }
      }
      catch (ClassNotFoundException e)

      { // won't happen we already checked that earlier }

      catch (Exception e)

      { // REVISIT: Localize this message. throw new RuntimeException( "Failed to create document object of class: " + fDocumentClassName); }

      }
      fCurrentNode = fDocument;
      }
      else

      { fDeferredDocumentImpl = new DeferredDocumentImpl(fNamespaceAware); fDocument = fDeferredDocumentImpl; fDocumentIndex = fDeferredDocumentImpl.createDeferredDocument(); // REVISIT: when DOM Level 3 is REC rely on // Document.support instead of specific class fDeferredDocumentImpl.setStrictErrorChecking(false); // set actual encoding fDeferredDocumentImpl.setActualEncoding(encoding); // set documentURI fDeferredDocumentImpl.setDocumentURI(locator.getExpandedSystemId()); fCurrentNodeIndex = fDocumentIndex; }

      } // startDocument(String,String)

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Guangtai Liang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development