]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix crash inside font-list-family
authorPo Lu <luangruo@yahoo.com>
Mon, 20 Feb 2023 03:56:13 +0000 (11:56 +0800)
committerPo Lu <luangruo@yahoo.com>
Mon, 20 Feb 2023 03:56:13 +0000 (11:56 +0800)
* src/androidfont.c (androidfont_list_family): Don't
unconditionally initialize the Android font driver.

src/androidfont.c

index 55f457583520fd69adea9ab7a148e0f3574ef19d..9da82b670fdbca22483953fba42b51734e6b171e 100644 (file)
@@ -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);