[ 
https://issues.apache.org/jira/browse/XERCESJ-1567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mukul Gandhi updated XERCESJ-1567:
----------------------------------
    Fix Version/s: 2.12.0

> ArrayIndexOutOfBoundsException in XSConstraints
> -----------------------------------------------
>
>                 Key: XERCESJ-1567
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1567
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.0 Structures, XML Schema 1.1 Structures
>    Affects Versions: 2.11.0
>            Reporter: Radu Coravu
>            Assignee: Michael Glavassevich
>            Priority: Major
>             Fix For: 2.12.0
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> 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) {
>                     return true;
>                 }
>             }
>         }
> --------------------------------------
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: j-dev-h...@xerces.apache.org

Reply via email to