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=21537>.
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=21537

XSLTC ArrayIndexOutOfBounds during StepIterator clone

           Summary: XSLTC ArrayIndexOutOfBounds during StepIterator clone
           Product: XalanJ2
           Version: 2.5Dx
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xalan.xsltc
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


After consistent TransformerExceptions from XSLTC, changed error reporting and 
traced the issue down to an ArrayIndexOutOfBounds exception in 
xsltc.utils.IntegerArray during a StepIterator.clone().  This happens when the 
requested size of the IntegerArray being cloned is 0, and IntegerArray.add
(int) is subsequently called.

The problem is in the following from IntegerArray:

    private void growArray(int size) {
        // Should test for size = 0
        // Maybe:
        // 
        // if (size == 0)
        //   size++
        //
        final int[] newArray = new int[_size = size];
        System.arraycopy(_array, 0, newArray, 0, _free);
        _array = newArray;
    }

The exception is thrown by the following:

    public final void add(int value) {
        // Doesn't work for _size = 0
        if (_free == _size) {
            growArray(_size * 2);
        }
        // Array with 0 elements throws ArrayIndexOutOfBounds
        _array[_free++] = value;
    }

Thanks,

-- APL

Reply via email to