RFR: 8282628: Potential memory leak in sun.font.FontConfigManager.getFontConfig() [v2]
Alexey Ivanov
aivanov at openjdk.java.net
Tue Mar 8 20:51:07 UTC 2022
On Tue, 8 Mar 2022 15:54:45 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:
>> Please review this small patch that fixes a potential memory leak that exception return fails to release allocated `cacheDirs`
>>
>> Test:
>>
>> - [x] jdk_desktop on Linux x86_64
>
> Zhengyu Gu has updated the pull request incrementally with one additional commit since the last revision:
>
> mrserb and aivanov-jdk's comments
> > > I did a quick grep, there are a few suspicious spots, e.g. https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp#L2711, I have yet take a close look.
> >
> >
> > It doesn't leak the icon handle here, it's assigned to the member of the object (probably `NULL`). Yet it's inconsistent: if an exception is expected from `CreateIconFromRaster` on the line above, why isn't it checked after `CreateIconFromRaster` is called on the following line?
>
> I am not familiar with this code. What I see is that, it assigns `m_hIcon` and `m_hIconSm` to local variables, then reset them to `NULL`, once exception returns, are references to icon and small icon handles lost? and it will destroy icons as L2727 - 2732 do. But I may miss something.
You're right. The old icon handles in `hOldIcon` and `hOldIconSm` will be leaked here if `CreateIconFromRaster` throws an exception.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7691
More information about the core-libs-dev
mailing list