From fecd0a9fed2f392dc0c5f852b705758681ef5266 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 20 Feb 2023 11:56:13 +0800 Subject: [PATCH] Fix crash inside font-list-family * src/androidfont.c (androidfont_list_family): Don't unconditionally initialize the Android font driver. --- src/androidfont.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/androidfont.c b/src/androidfont.c index 55f45758352..9da82b670fd 100644 --- a/src/androidfont.c +++ b/src/androidfont.c @@ -1027,18 +1027,19 @@ androidfont_list_family (struct frame *f) jsize i, length; const char *family; - /* Maybe initialize the font driver. */ - androidfont_check_init (); + /* Return if the Android font driver is not initialized. Loading + every font under Android takes a non trivial amount of memory, + and is not something that should be done when the user tries to + list all of the font families. */ + + if (!font_driver) + return Qnil; family_array = (*android_java_env)->CallObjectMethod (android_java_env, font_driver, font_driver_class.list_families); - if (!family_array) - { - (*android_java_env)->ExceptionClear (android_java_env); - memory_full (0); - } + android_exception_check (); length = (*android_java_env)->GetArrayLength (android_java_env, family_array); -- 2.39.5