[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android f9e68ed00e4 2/3: Fix occasional crash
From: |
Po Lu |
Subject: |
feature/android f9e68ed00e4 2/3: Fix occasional crash |
Date: |
Wed, 8 Mar 2023 07:07:26 -0500 (EST) |
branch: feature/android
commit f9e68ed00e469d841c58681cd9d06e3d985614ad
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Fix occasional crash
* 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 | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/androidterm.c b/src/androidterm.c
index f4a535292f2..b502b1c6de5 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -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);
+ }
}
}