Subject: 26.3, 27.1-rc1, master: Emacs (X11) segfaults if XIM is set but not XIM_Styles
From: Grégory Mounié <[email-masked]>
To: [email-masked]
Date: Sun, 2 Aug 2020 16:36:32 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello

  Emacs (emacs -Q with X11) segfaults in xfns.c (create_frame_xic), at 
its initialization, if XIM pointer is set, but not XIM_styles pointer.

  The patch extends the check on xim pointer to add the XIM_Styles 
pointer too.

  The code is at least several years old (git blame write "2014-03" in 
26.3 branch). The bug is present in master, 27.1-rc1 and 26.3 branch.

  The bug triggers today in my settings (emacs 26.3 from my debian/sid 
with gdm3 and windowmaker), but I do not know exactly why yet.

  Have a nice day
  Grégory Mounié
From 280e1f965e5a4d2521f2c282be6348144f687ee6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9gory=20Mouni=C3=A9?= <[email-masked]>
Date: Sun, 2 Aug 2020 15:56:33 +0200
Subject: [PATCH] Emacs segfaults if xim is set but not xim_styles

Emacs segfaults at the X11 initialization if XIM is set
and xim_styles is NULL.

* src/xfns.c: Check also if FRAME_X_XIM_STYLES(f) is NULL
---
 src/xfns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xfns.c b/src/xfns.c
index 2ab5080d97..09dcbbfb92 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2652,7 +2652,7 @@ create_frame_xic (struct frame *f)
     goto out;
 
   xim = FRAME_X_XIM (f);
-  if (!xim)
+  if (!xim || ! FRAME_X_XIM_STYLES(f))
     goto out;
 
   /* Determine XIC style.  */
-- 
2.28.0