RFR: 8282628: Potential memory leak in sun.font.FontConfigManager.getFontConfig()

Zhengyu Gu zgu at openjdk.java.net
Tue Mar 8 15:38:06 UTC 2022


On Fri, 4 Mar 2022 13:25:12 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

> 



> > The macros are used to hide the different syntax of c and c++ to avoid polluting code here, it seems to be a common pattern in client code.
> 
> That's to allow for general use by C or C++ source files. But you are only needing this in a C source file so you would only need the C variant of the calling syntax.



> > The macros are used to hide the different syntax of c and c++ to avoid polluting code here, it seems to be a common pattern in client code.
> 
> That's to allow for general use by C or C++ source files. But you are only needing this in a C source file so you would only need the C variant of the calling syntax.

I don't like the macros. I can argument all `JNU_CHECK_EXCEPTION(_RETURN)` macros are particular bad, because these patterns can easily result premature returns without proper cleanup. This bug is an evidence. But they exist for a long time, and I just follow the convention :-( I would prefer to eliminate them all, as inline code is not big at all.

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](url), I have yet take a close look.

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

PR: https://git.openjdk.java.net/jdk/pull/7691



More information about the client-libs-dev mailing list