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

David Holmes dholmes at openjdk.java.net
Tue Mar 8 12:23:57 UTC 2022


On Tue, 8 Mar 2022 09:20:19 GMT, Sergey Bylokhov <serb 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
>
> src/java.desktop/unix/native/common/awt/fontpath.c line 940:
> 
>> 938:                 JNU_CHECK_EXCEPTION_AND_CLEANUP(env, (*FcStrListDone)(cacheDirs));
>> 939: 
>> 940:                 (*env)->SetObjectArrayElement(env, cacheDirArray, cnt++, jstr);
> 
> Probably we should add the check+cleanup after the SetObjectArrayElement? Otherwise, we may call NewStringUTF while an exception is raised by the SetObjectArrayElement.

??? You want to check and cleanup if NewStringUTF fails. You only want to call SetObjectElementArray if NewStringUTF succeeds.

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

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


More information about the core-libs-dev mailing list