Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-878

IntStack throws ArrayIndexOutOfBoundsException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 2.7.1
    • None
    • Other
    • None
    • Operating System: Other
      Platform: Other
    • 6854

    Description

      In a complicated Cocoon2 pipeline, we get consistent error in IntStack. The
      same error cannot be recreated if we export our XML into a file and then run
      the stylesheet on it. But the good news is that the following patch works.
      Basically if the array index is less then zero, the code should throw an
      EmptyStackException. This is documented by the javadoc but not implemented in
      current cvs

      Index: src/org/apache/xml/utils/IntStack.java
      ===================================================================
      RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/IntStack.java,v
      retrieving revision 1.5
      diff -d -u -b -B -w -u -r1.5 IntStack.java
      — src/org/apache/xml/utils/IntStack.java 21 Jun 2001 18:52:52 -0000
      1.5
      +++ src/org/apache/xml/utils/IntStack.java 4 Mar 2002 17:51:50 -0000
      @@ -145,7 +145,10 @@
      */
      public int peek()

      { - return m_map[m_firstFree - 1]; + int index = m_firstFree - 1; + if(index < 0) + throw new EmptyStackException(); + return m_map[index]; }

      /**
      @@ -157,7 +160,10 @@
      */
      public int peek(int n)

      { - return m_map[m_firstFree-(1+n)]; + int index = m_firstFree-(1+n); + if(index < 0) + throw new EmptyStackException(); + return m_map[index]; }

      /**

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--patch.txt
          0.9 kB
          Davanum Srinivas

        Activity

          People

            Unassigned Unassigned
            dims@yahoo.com Davanum Srinivas
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: