#287 ArrayIndexOutOfBounds in TinyTree.condense

v8.2
closed
Michael Kay
5
2012-10-08
2005-01-05
Michael Kay
No

If the number of nodes in a tiny tree is exactly equal
to the size of the arrays allocated to hold the nodes,
Saxon will fail with an ArrayIndexOutOfBoundsException
when closing the tree. A typical stack trace starts
like this:

java.lang.ArrayIndexOutOfBoundsException: 50
at
net.sf.saxon.tinytree.TinyTree.condense(TinyTree.java:330)
at
net.sf.saxon.tinytree.TinyBuilder.close(TinyBuilder.java:145)
at
net.sf.saxon.event.ProxyReceiver.close(ProxyReceiver.java:97)
at
net.sf.saxon.event.ComplexContentOutputter.close(ComplexContentOutputter.java:417)

Source fix (not tested): in
net.sf.saxon.tinytree.TinyTree, at the start of method
condense() on line 304, change the if() condition to:

if (numberOfNodes * 3 < nodeKind.length ||
(nodeKind.length - numberOfNodes >
20000) ||
numberOfNodes == nodeKind.length) {

The problem is new in 8.2.

Discussion

  • Michael Kay
    Michael Kay
    2005-01-06

    Logged In: YES
    user_id=251681

    The problem has now been reproduced and the source fix above
    is confirmed to be OK.