You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/08/05 11:43:18 UTC
DO NOT REPLY [Bug 22128] New: -
org.apache.xml.dtm.ref.DTMDefaultBase (SuballocatedIntVector)-index-error
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22128>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22128
org.apache.xml.dtm.ref.DTMDefaultBase (SuballocatedIntVector)-index-error
Summary: org.apache.xml.dtm.ref.DTMDefaultBase
(SuballocatedIntVector)-index-error
Product: XalanJ2
Version: 2.5
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: org.apache.xml.dtm
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: oliver.haider@hvbsystems.com
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
}