From: Po Lu Date: Sun, 19 Feb 2023 02:47:32 +0000 (+0800) Subject: Fix crashes in desktop-save-mode X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c6809eb92780f8206423898151cc40c959921753;p=emacs.git 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 . --- 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 }