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

Alexey Ivanov aivanov at openjdk.java.net
Tue Mar 8 13:40:57 UTC 2022


On Tue, 8 Mar 2022 12:20:38 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> 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.

Can `SetObjectElementArray` raise an exception?  
The index is within the array length and we store a string. I assume `cacheDirArray` is a string array.

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

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


More information about the core-libs-dev mailing list