On Fri, 17 Jan 2025 18:22:57 GMT, Rajat Mahajan <rmaha...@openjdk.org> wrote:

>> **Issue:** 
>> AwtWindow::SetIconData leaks the old icon handles in hOldIcon and hOldIconSm 
>> if CreateIconFromRaster raises an exception. Additionally, an exception is 
>> checked only after the first call to CreateIconFromRaster.
>> 
>> **Solution:**
>> I have added the exception handling code to take care that the handles are 
>> properly destroyed and not leaked.
>> 
>> **Testing:**
>> I have tested the code to make sure there are no regressions caused by this.
>
> Rajat Mahajan has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   check using not equal to NULL to match the rest of the code in the function

While I was looking deeper into the code flow, I found another place which 
needs changing.

https://github.com/openjdk/jdk/blob/0fbf10a9cf51d01d82cd43cf0edfaeee83313a9c/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp#L126-L132

The JNI method `Java_sun_awt_windows_WTaskbarPeer_setOverlayIcon` for 
`WTaskbarPeer.setOverlayIcon` calls `CreateIconFromRaster` that can throw a C++ 
exception.

The call to `CreateIconFromRaster` has to be wrapped into a try-catch block to 
ensure the C++ exception does not escape.

I think it's reasonable to address this new issue under a new bugid.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22932#issuecomment-2602772897

Reply via email to