From: Po Lu Date: Fri, 13 Jan 2023 08:08:11 +0000 (+0800) Subject: Fix crashes in Android port X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=24910d3f375a11360c66b742e1054b55e9e25ccc;p=emacs.git Fix crashes in Android port * java/org/gnu/emacs/EmacsService.java (queryTree): Fix NULL pointer dereference. * src/android.c (android_query_tree): Set *nchildren_return. --- diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 01a1695f385..c008300dd3a 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java @@ -304,7 +304,9 @@ public class EmacsService extends Service array = new short[windowList.size () + 1]; i = 1; - array[0] = window.parent != null ? 0 : window.parent.handle; + array[0] = (window == null + ? 0 : (window.parent != null + ? window.parent.handle : 0)); for (EmacsWindow treeWindow : windowList) array[i++] = treeWindow.handle; diff --git a/src/android.c b/src/android.c index eab18dc6152..fba43129ee3 100644 --- a/src/android.c +++ b/src/android.c @@ -3148,6 +3148,7 @@ android_query_tree (android_window handle, android_window *root_return, *root_return = 0; *parent_return = shorts[0]; *children_return = children; + *nchildren_return = nelements - 1; /* Release the array contents. */ (*android_java_env)->ReleaseShortArrayElements (android_java_env, array,