From 5df2a057707eb65148f96710bd57d8dd8d85d1ed Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 9 Mar 2022 13:27:11 +0000 Subject: [PATCH] 8282628: Potential memory leak in sun.font.FontConfigManager.getFontConfig() Reviewed-by: stuefe, dholmes, aivanov --- src/java.desktop/unix/native/common/awt/fontpath.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/java.desktop/unix/native/common/awt/fontpath.c b/src/java.desktop/unix/native/common/awt/fontpath.c index c4b2fcb73c0..051c9de88fa 100644 --- a/src/java.desktop/unix/native/common/awt/fontpath.c +++ b/src/java.desktop/unix/native/common/awt/fontpath.c @@ -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); }