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=15040>. 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=15040 Empty comment causes ArrayIndexOutOfBoundsException Summary: Empty comment causes ArrayIndexOutOfBoundsException Product: XalanJ2 Version: 2.4 Platform: All OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: org.apache.xalan.serialize AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Serializing empty comments causes an ArrayIndexOutOfBoundsException. This is caused by the following line in SerializerToXML.comment(): if (ch[limit-1] == '-') The limit is set to start + length and so if start == length == 0 then this will attempt to access ch[-1] and so AIOBE. If start > 0 then it may just access an incorrect element (hopefully length will never be < 0). I would assume that a proper solution would either be to do: if ( length <= 0 ) return; at the top of the procedure (which would cause nothing to be written for the empty comment), or if it is desireable to show the empty comment then maybe the offending line could be modified as: if (length > 0 && ch[limit-1] == '-') This would cause output like "<!---->" which I am not sure is exactly correct. If this is not correct then perhaps the first solution I suggested could be modified to something like: if ( length <= 0 ) { writer.write("<!-- -->"); return; }
