[13] RFR: 8210583: Base64.Encoder incorrectly throws NegativeArraySizeException

Nishit Jain nishit.jain at oracle.com
Thu Jan 17 07:07:18 UTC 2019


Hi,

Please review the fix for 8210583

Bug: https://bugs.openjdk.java.net/browse/JDK-8210583
Webrev: http://cr.openjdk.java.net/~nishjain/8210583/webrev.03/
CSR: https://bugs.openjdk.java.net/browse/JDK-8215633

Issue: Base64.Encoder.encode and Base64.Decoder.decode methods 
incorrectly throw unspecified exception e.g. NegativeArraySizeException, 
when the input byte array size is too large such that the calculated 
output byte size goes beyond the max-integer boundary and wraps around.

Fix: Throw an OutOfMemoryError if the output byte array/buffer or memory 
can not be allocated. There is an unrelated change in 
encodeToString(byte[]) where a string instance is created using 
JavaLangAccess.newStringNoRepl(byte[], ISO_8859_1)instead of string 
constructor, to save memory.

Regards,
Nishit Jain


More information about the core-libs-dev mailing list