[ http://issues.apache.org/jira/browse/XALANJ-1625?page=all ]

Brian Minchau updated XALANJ-1625:
----------------------------------

    Version: Latest Development Code
                 (was: 2.5)

> org.apache.xml.dtm.ref.DTMDefaultBase  (SuballocatedIntVector)-index-error
> --------------------------------------------------------------------------
>
>          Key: XALANJ-1625
>          URL: http://issues.apache.org/jira/browse/XALANJ-1625
>      Project: XalanJ2
>         Type: Bug
>   Components: DTM
>     Versions: Latest Development Code
>  Environment: Operating System: Other
> Platform: Other
>     Reporter: Oliver Haider
>     Assignee: Xalan Developers Mailing List

>
> There is a misshap in the class bug in org.apache.xml.dtm.ref.DTMDefaultBase 
> (at the  function SuballocatedIntVector)
> In the last few lines the local var candiate is assigned 
> (candidate=m_namespaceDeclSetElements.elementAt(--wouldBeAt);)
> the problem is the --wouldBeAt since it is checked for >= 0 thus it might be 
> 0 
> and then in the get-function -1.
> regards
> oliver haider
>   protected SuballocatedIntVector findNamespaceContext(int elementNodeIndex)
>   {
>     if (null!=m_namespaceDeclSetElements)
>       {
>         // %OPT% Is binary-search really saving us a lot versus linear?
>         // (... It may be, in large docs with many NS decls.)
>         int wouldBeAt=findInSortedSuballocatedIntVector
> (m_namespaceDeclSetElements,
>                                             elementNodeIndex);
>         if(wouldBeAt>=0) // Found it
>           return (SuballocatedIntVector) m_namespaceDeclSets.elementAt
> (wouldBeAt);
>         if(wouldBeAt == -1) // -1-wouldbeat == 0
>           return null; // Not after anything; definitely not found
>         // Not found, but we know where it should have been.
>         // Search back until we find an ancestor or run out.
>         wouldBeAt=-1-wouldBeAt;
>         // Decrement wouldBeAt to find last possible ancestor
>         int candidate=m_namespaceDeclSetElements.elementAt(-- wouldBeAt);
>         int ancestor=_parent(elementNodeIndex);
>         // Special case: if the candidate is before the given node, and
>         // is in the earliest possible position in the document, it
>         // must have the namespace declarations we're interested in.
>         if (wouldBeAt == 0 && candidate < ancestor) {
>           int rootHandle = getDocumentRoot(makeNodeHandle(elementNodeIndex));
>           int rootID = makeNodeIdentity(rootHandle);
>           int uppermostNSCandidateID;
>           if (getNodeType(rootHandle) == DTM.DOCUMENT_NODE) {
>             int ch = _firstch(rootID);
>             uppermostNSCandidateID = (ch != DTM.NULL) ? ch : rootID;
>           } else {
>             uppermostNSCandidateID = rootID;
>           }
>           if (candidate == uppermostNSCandidateID) {
>             return (SuballocatedIntVector)m_namespaceDeclSets.elementAt
> (wouldBeAt);
>           }
>         }
>         while(wouldBeAt>=0 && ancestor>0)
>           {
>             if (candidate==ancestor) {
>                 // Found ancestor in list
>                 return (SuballocatedIntVector)m_namespaceDeclSets.elementAt
> (wouldBeAt);
>             } else if (candidate<ancestor) {
>                 // Too deep in tree
>                 do {
>                   ancestor=_parent(ancestor);
>                 } while (candidate < ancestor);
>             } else {
>               // Too late in list
>               candidate=m_namespaceDeclSetElements.elementAt(--wouldBeAt);
>             }
>           }
>       }
>     return null; // No namespaces known at this node
>   }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to