Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.11.0
-
None
Description
I'm integrating "Xerces-J 2.11.0-xml-schema-1.1-beta" in Oxygen XML Editor.
After the integration one of our automated tests caught this ArrayIndexOutOfBoundsException:
------------------------
java.lang.ArrayIndexOutOfBoundsException: 2
at org.apache.xerces.impl.xs.XSConstraints.overlapUPA(XSConstraints.java:610)
at org.apache.xerces.impl.xs.XSConstraints.overlapUPA(XSConstraints.java:639)
at org.apache.xerces.impl.xs.models.XSAllCM.checkUniqueParticleAttribution(Unknown Source)
at org.apache.xerces.impl.xs.XSConstraints.fullSchemaChecking(XSConstraints.java:481)
at org.apache.xerces.impl.xs.XMLSchemaValidatorXerces.handleEndElement(XMLSchemaValidatorXerces.java:2568)
at org.apache.xerces.impl.xs.XMLSchemaValidatorXerces.endElement(XMLSchemaValidatorXerces.java:922)
at com.thaiopensource.validate.xerces.ValidatorImpl.endElement(ValidatorImpl.java:186)
at com.thaiopensource.validate.nvdl.ValidatorImpl.endElement(ValidatorImpl.java:719)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
--------------------------------------------------
the code where this happens is like:
------------------------------------
// or if the 2 substitution groups overlap.
for (int i = subGroup1.length-1; i >= 0; i--) {
for (int j = subGroup2.length-1; j >= 0; j--) {
if (subGroup1[i].fName == subGroup2[i].fName &&
subGroup1[i].fTargetNamespace == subGroup2[i].fTargetNamespace)
}
}
--------------------------------------
So there are two "for" loops but the index in the first loop is used in both array entries which are compared.
The code should probably use the "j" index in the second array like:
--------------------------------------
// or if the 2 substitution groups overlap.
for (int i = subGroup1.length-1; i >= 0; i--) {
for (int j = subGroup2.length-1; j >= 0; j--) {
//OXYGEN PATCH, correctly use index when comparing
if (subGroup1[i].fName == subGroup2[j].fName &&
subGroup1[i].fTargetNamespace == subGroup2[j].fTargetNamespace) { return true; }
}
}
-----------------------------------------
Unfortunately I do not have a simple test for this, we had an automated test which validated an XML document against the OOXML XML Schemas available in an Oxygen installation.