Skip to content

Commit

Permalink
fix a memory leak in XRegisterIMInstantiateCallback
Browse files Browse the repository at this point in the history
Analysis:

    _XimRegisterIMInstantiateCallback() opens an XIM and closes it using
    the internal function pointers, but the internal close function does
    not free the pointer to the XIM (this would be done in XCloseIM()).

Report/patch:

    Date: Mon, 03 Oct 2022 18:47:32 +0800
    From: Po Lu <luangruo@yahoo.com>
    To: xorg-devel@lists.x.org
    Subject: Re: Yet another leak in Xlib

    For reference, here's how I'm calling XRegisterIMInstantiateCallback:

    XSetLocaleModifiers ("");
    XRegisterIMInstantiateCallback (compositor.display,
                                    XrmGetDatabase (compositor.display),
                                    (char *) compositor.resource_name,
                                    (char *) compositor.app_name,
                                    IMInstantiateCallback, NULL);

    and XMODIFIERS is:

        @im=ibus

Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
  • Loading branch information
ThomasDickey committed Oct 4, 2022
1 parent 1f8fd7f commit 1d11822
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/im/ximcp/imInsClbk.c
Expand Up @@ -212,6 +212,9 @@ _XimRegisterIMInstantiateCallback(
if( xim ) {
lock = True;
xim->methods->close( (XIM)xim );
/* XIMs must be freed manually after being opened; close just
does the protocol to deinitialize the IM. */
XFree( xim );
lock = False;
icb->call = True;
callback( display, client_data, NULL );
Expand Down

0 comments on commit 1d11822

Please sign in to comment.