]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix occasional crash
authorPo Lu <luangruo@yahoo.com>
Wed, 8 Mar 2023 12:06:41 +0000 (20:06 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 8 Mar 2023 12:06:41 +0000 (20:06 +0800)
* src/androidterm.c (android_build_extracted_text): Return NULL
if text class not initialized.
(android_update_selection): Check that EXTRACTED is not NULL.

src/androidterm.c

index f4a535292f233d8ef86622ed03b140d4038b535e..b502b1c6de550dbcbdd4e26df9eb85a6202d02c4 100644 (file)
@@ -5080,6 +5080,10 @@ android_build_extracted_text (jstring text, ptrdiff_t start,
 
   env = android_java_env;
 
+  /* Return NULL if the class has not yet been obtained.  */
+  if (!text_class.class)
+    return NULL;
+
   /* Create an ExtractedText object containing this information.  */
   object = (*env)->NewObject (env, text_class.class,
                              text_class.constructor);
@@ -5333,11 +5337,14 @@ android_update_selection (struct frame *f, struct window *w)
       android_exception_check_1 (string);
       ANDROID_DELETE_LOCAL_REF (string);
 
-      /* extracted is now an associated ExtractedText object.  Perform
-        the update.  */
-      android_update_extracted_text (FRAME_ANDROID_WINDOW (f),
-                                    extracted, token);
-      ANDROID_DELETE_LOCAL_REF (extracted);
+      if (extracted)
+       {
+         /* extracted is now an associated ExtractedText object.
+            Perform the update.  */
+         android_update_extracted_text (FRAME_ANDROID_WINDOW (f),
+                                        extracted, token);
+         ANDROID_DELETE_LOCAL_REF (extracted);
+       }
     }
 }