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

Reviewed-by: stuefe, dholmes, aivanov
This commit is contained in:
Zhengyu Gu 2022-03-09 13:27:11 +00:00
parent d07f7c76c5
commit 5df2a05770

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -935,8 +935,10 @@ Java_sun_font_FontConfigManager_getFontConfig
if (cacheDirs != NULL) {
while ((cnt < max) && (cacheDir = (*FcStrListNext)(cacheDirs))) {
jstr = (*env)->NewStringUTF(env, (const char*)cacheDir);
JNU_CHECK_EXCEPTION(env);
if (IS_NULL(jstr)) {
(*FcStrListDone)(cacheDirs);
return;
}
(*env)->SetObjectArrayElement(env, cacheDirArray, cnt++, jstr);
(*env)->DeleteLocalRef(env, jstr);
}