RFR: 8282862: AwtWindow::SetIconData leaks old icon handles if an exception is detected [v2]
Harshitha Onkar
honkar at openjdk.org
Tue Jan 7 00:44:40 UTC 2025
On Mon, 6 Jan 2025 21:14:50 GMT, Rajat Mahajan <rmahajan at 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:
>
> fix indentation and make sure we delete both handles.
Please update the copyright year for .cpp file.
Is there a way to test this fix or possibly add a test case?
src/java.desktop/windows/native/libawt/windows/awt_Window.cpp line 2138:
> 2136: DestroyIcon(m_hIconSm);
> 2137: }
> 2138: throw; // Re-throw the exception
Looks good here. I suppose you are cleaning up the resources in catch block since finally block isn't available in C++.
-------------
PR Review: https://git.openjdk.org/jdk/pull/22932#pullrequestreview-2533191469
PR Review Comment: https://git.openjdk.org/jdk/pull/22932#discussion_r1904775064
More information about the client-libs-dev
mailing list