You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Guangtai Liang (Created) (JIRA)" <xe...@xml.apache.org> on 2012/02/13 09:13:00 UTC
[jira] [Created] (XERCESJ-1555) An incomplete fix for the NPE bugs
in AbstractDOMParser.java
An incomplete fix for the NPE bugs in AbstractDOMParser.java
------------------------------------------------------------
Key: XERCESJ-1555
URL: https://issues.apache.org/jira/browse/XERCESJ-1555
Project: Xerces2-J
Issue Type: Bug
Components: Other
Reporter: Guangtai Liang
Priority: Critical
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)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
[jira] [Resolved] (XERCESJ-1555) An incomplete fix for the NPE bugs
in AbstractDOMParser.java
Posted by "Michael Glavassevich (Resolved) (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESJ-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Glavassevich resolved XERCESJ-1555.
-------------------------------------------
Resolution: Invalid
In practice the XMLLocator is never null. Also the line numbers you cite do not align with the current code, so have no idea what release you're looking at.
> An incomplete fix for the NPE bugs in AbstractDOMParser.java
> ------------------------------------------------------------
>
> Key: XERCESJ-1555
> URL: https://issues.apache.org/jira/browse/XERCESJ-1555
> Project: Xerces2-J
> Issue Type: Bug
> Components: Other
> Reporter: Guangtai Liang
> Priority: Critical
> Labels: incomplete_fix, missing_fixes
>
> 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)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org