emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/android c6809eb9278 2/2: Fix crashes in desktop-save-mode


From: Po Lu
Subject: feature/android c6809eb9278 2/2: Fix crashes in desktop-save-mode
Date: Sat, 18 Feb 2023 21:47:53 -0500 (EST)

branch: feature/android
commit c6809eb92780f8206423898151cc40c959921753
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix crashes in desktop-save-mode
    
    * lisp/subr.el (overriding-text-conversion-style, y-or-n-p):
    Disable text conversion when reading from minibuffer.
    * src/androidfns.c (android_make_monitor_attribute_list): New
    function.
    (Fandroid_display_monitor_attributes_list): Call it to set
    monitor_frames, which avoids a NULL pointer dereference.
    Reported by Angelo Graziosi <angelo.g0@libero.it>.
---
 lisp/subr.el     |  6 ++++++
 src/androidfns.c | 37 ++++++++++++++++++++++++++++++++++---
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 33865aa326c..a64346fadf8 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3590,6 +3590,9 @@ character.  This is not possible when using `read-key', 
but using
            from--tty-menu-p)            ; invoked via TTY menu
        use-dialog-box))
 
+;; Actually in textconv.c.
+(defvar overriding-text-conversion-style)
+
 (defun y-or-n-p (prompt)
   "Ask user a \"y or n\" question.
 Return t if answer is \"y\" and nil if it is \"n\".
@@ -3696,6 +3699,9 @@ like) while `y-or-n-p' is running)."
       (setq prompt (funcall padded prompt))
       (let* ((enable-recursive-minibuffers t)
              (msg help-form)
+             ;; Disable text conversion so that real Y or N events are
+             ;; sent.
+             (overriding-text-conversion-style nil)
              (keymap (let ((map (make-composed-keymap
                                  y-or-n-p-map query-replace-map)))
                        (when help-form
diff --git a/src/androidfns.c b/src/androidfns.c
index 77ee2e8de44..b5b88df4fe5 100644
--- a/src/androidfns.c
+++ b/src/androidfns.c
@@ -1285,6 +1285,39 @@ DEFUN ("x-display-visual-class", Fx_display_visual_class,
   return Qtrue_color;
 }
 
+#ifndef ANDROID_STUBIFY
+
+static Lisp_Object
+android_make_monitor_attribute_list (struct MonitorInfo *monitors,
+                                    int n_monitors,
+                                    int primary_monitor)
+{
+  Lisp_Object monitor_frames;
+  Lisp_Object frame, rest;
+  struct frame *f;
+
+  monitor_frames = make_nil_vector (n_monitors);
+
+  FOR_EACH_FRAME (rest, frame)
+    {
+      f = XFRAME (frame);
+
+      /* Associate all frames with the primary monitor.  */
+
+      if (FRAME_WINDOW_P (f)
+         && !FRAME_TOOLTIP_P (f))
+       ASET (monitor_frames, primary_monitor,
+             Fcons (frame, AREF (monitor_frames,
+                                 primary_monitor)));
+    }
+
+  return make_monitor_attribute_list (monitors, n_monitors,
+                                     primary_monitor,
+                                      monitor_frames, NULL);
+}
+
+#endif
+
 DEFUN ("android-display-monitor-attributes-list",
        Fandroid_display_monitor_attributes_list,
        Sandroid_display_monitor_attributes_list,
@@ -1312,9 +1345,7 @@ Internal use only, use `display-monitor-attributes-list' 
instead.  */)
   monitor.work = monitor.geom;
   monitor.name = (char *) "Android device monitor";
 
-  /* What to do about monitor_frames? */
-  return make_monitor_attribute_list (&monitor, 1,
-                                     0, Qnil, NULL);
+  return android_make_monitor_attribute_list (&monitor, 1, 0);
 #endif
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]