[
Lists Home |
Date Index |
Thread Index
]
- From: Sebastien Sahuc <ssahuc@imediation.com>
- To: David Megginson <david@megginson.com>, xml-dev@lists.xml.org
- Date: Wed, 18 Oct 2000 22:23:23 +0100
Title: [SAX2] BUG in AttributesImpl
Hi,
I Still can't believe I'm reporting a bug in SAX2 :-)
Description :
-------------
When creating a new AttributesImpl instance and calling on it the method setAttributes(atts) with an attributes object that has NO attributes values, then the method addAttributes() go into an infinite loop.
Explanation :
-------------
Calling the setAttributes(atts) with atts.getLength() equals to zero creates a internal 'data' object of type String[0], which length is used later in the ensureCapacity() method :
...
int max = data.length;
...
while (max < n * 5) {
max *= 2; <------- Here it hurts : max = 0 ALWAYS !!!
}
...
BUG FIX :
---------
So a fix should be to replace the beginning of the ensureCapacity method.
WAS :
private void ensureCapacity (int n)
{
if (n > 0 && data == null ) {
data = new String[25];
}
...
SHOULD BE :
private void ensureCapacity (int n)
{
if (n > 0 && (data == null || data.length == 0) ) {
data = new String[25];
}
...
Regards,
Sebastien Sahuc
|