RFR: 8282862: AwtWindow::SetIconData leaks old icon handles if an exception is detected [v2]

Alexey Ivanov aivanov at openjdk.org
Thu Jan 16 21:27:35 UTC 2025


On Tue, 7 Jan 2025 00:41:57 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

> Is there a way to test this fix or possibly add a test case?

@honkar-jdk I don't think it's possible to write a test for this case….

It my be tested by defining [`OUTOFMEM_TEST`](https://github.com/openjdk/jdk/blob/062f2dcfe5b62cc3dd3c292eeebd7a7ac78f849a/src/java.desktop/windows/native/libawt/windows/awt_new.cpp#L174C8-L174C21) in `awt_new.cpp` to enable random allocation failures.

Another way could be to change the source code to explicitly cause `std::bad_alloc` and/or a Java exception in any of the called methods. Just to validate the suggested fix really works… on top of static code analysis.

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

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


More information about the client-libs-dev mailing list