<AWT Dev> RFR: 8185739: Memory leak in BitmapUtil::BitmapToRgn

Phil Race philip.race at oracle.com
Mon Nov 6 20:01:44 UTC 2017


Bug: https://bugs.openjdk.java.net/browse/JDK-8185739
Webrev: http://cr.openjdk.java.net/~prr/8185739/

The complaint in the bug is about this code  ..
254 if (!IS_SAFE_SIZE_MUL(width / 2 + 1, height)) {
255 throw std::bad_alloc();

.. potentially leaking memory allocated and stored in "buf" if the 
exception is thrown.

This is indeed a potential leak but
- the same location is also failing to release "hdc"
- it is unclear why this needs to throw bad_alloc instead of returning 
NULL as
is happening elsewhere in this function and the only caller checks for NULL
and can handle it.
- There are two other return sites in the same function that may leak ..

I have updated all of these.


-phil.




More information about the awt-dev mailing list