[OpenJDK 2D-Dev] [9] Review Request: 8042103 Deserialization of empty java.awt.geom.Path2D will cause an exception

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Fri May 30 08:11:03 UTC 2014


added awt-dev@

On 23.05.2014 22:34, Sergey Bylokhov wrote:
> Hello,
> Any volunteers to review the fix?
> On 5/5/14 5:30 PM, Sergey Bylokhov wrote:
>> Hi, Jim.
>> On 01.05.2014 4:44, Jim Graham wrote:
>>> Hi Sergey,
>>>
>>> I think the bug is in the readObject routine.  It sets the initial 
>>> size of the arrays based on if the number of segments/coords is "< 
>>> 0" and it sets them to INIT_SIZE or INIT_SIZE*2 accordingly.  Those 
>>> tests should be "< INIT_SIZE(*2)"...
>>
>> It was my first thought, but we have an API, which allows to set 
>> starting value of capacity to 0.
>> Copy from the bug description:
>> 1.Path2D path = Path2D.Float(int rule, int initialCapacity); while 
>> initialCapacity is 0
>> 2.Path2D path = Path2D.Double(int rule, int initialCapacity);
>> 3.Path2D path = Path2D.Float(Shape s); while s is empty Path2D
>> 4.Path2D path = Path2D.Float(Shape s, AffineTransform at);
>> 5.Path2D path = Path2D.Double(Shape s);
>> 6.Path2D path = Path2D.Double(Shape s, AffineTransform at);
>>
>> based on these I assume that empty capacity is correct value, and 
>> needRoom should be ready for that.
>>
>>>
>>>             ...jim
>>>
>>> On 4/30/14 8:52 AM, Sergey Bylokhov wrote:
>>>> Hello.
>>>> Please review the fix for jdk 9.
>>>> needRoom() method does not take into account that current array of 
>>>> types
>>>> can be empty. In this case it fails to increase it.
>>>> I handle this case and increase the size of the array by 1 instead of
>>>> INIT_SIZE, because I assume that the user intentionally try to 
>>>> decrease
>>>> memory usage.
>>>>
>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8042103
>>>> Webrev can be found at: 
>>>> http://cr.openjdk.java.net/~serb/8042103/webrev.00
>>>>
>>
>>
>
>


-- 
Best regards, Sergey.




More information about the 2d-dev mailing list