On Tue, 8 Mar 2022 09:20:19 GMT, Sergey Bylokhov <s...@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

Reply via email to