From 8f706d160631f1ffdbfa16543a38b9d5f91c16ad Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 23 Mar 2023 13:07:38 +0900
Subject: [PATCH] util/IMdkit: Disable while loop before call
 ForwardEventMessageProc()

Seems ProcessQueue() had a wrong XFree() with async process-key-event.
Fixes: https://github.com/ibus/ibus/commit/506ac99

BUG=https://github.com/ibus/ibus/issues/2484
---
 util/IMdkit/i18nPtHdr.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/util/IMdkit/i18nPtHdr.c b/util/IMdkit/i18nPtHdr.c
index 8dc52714d..ec20e3228 100644
--- a/util/IMdkit/i18nPtHdr.c
+++ b/util/IMdkit/i18nPtHdr.c
@@ -1747,11 +1747,13 @@ static void ProcessQueue (XIMS ims, CARD16 connect_id)
         XimProtoHdr *hdr = (XimProtoHdr *) client->pending->p;
         unsigned char *p1 = (unsigned char *) (hdr + 1);
         IMProtocol call_data;
+        XIMPending *old = client->pending;
 
         call_data.major_code = hdr->major_opcode;
         call_data.any.minor_code = hdr->minor_opcode;
         call_data.any.connect_id = connect_id;
 
+        client->pending = old->next;
         switch (hdr->major_opcode)
         {
         case XIM_FORWARD_EVENT:
@@ -1760,12 +1762,7 @@ static void ProcessQueue (XIMS ims, CARD16 connect_id)
         }
         /*endswitch*/
         XFree (hdr);
-        {
-            XIMPending *old = client->pending;
-
-            client->pending = old->next;
-            XFree (old);
-        }
+        XFree (old);
     }
     /*endwhile*/
     return;
