From: Po Lu Date: Wed, 8 Mar 2023 12:06:41 +0000 (+0800) Subject: Fix occasional crash X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f9e68ed00e469d841c58681cd9d06e3d985614ad;p=emacs.git 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. --- 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); + } } }