Yet another leak in Xlib

Po Lu luangruo at yahoo.com
Mon Oct 3 10:47:32 UTC 2022


Po Lu <luangruo at yahoo.com> writes:

> ==67186== 408 bytes in 1 blocks are definitely lost in loss record 272 of 344
> ==67186==    at 0x484A464: calloc (vg_replace_malloc.c:1328)
> ==67186==    by 0x490935F: _XimOpenIM (in /usr/lib64/libX11.so.6.4.0)
> ==67186==    by 0x490F386: _XimRegisterIMInstantiateCallback (in /usr/lib64/libX11.so.6.4.0)
> ==67186==    by 0x48FBDBD: XRegisterIMInstantiateCallback (in /usr/lib64/libX11.so.6.4.0)
> ==67186==    by 0x4456B5: tiInitTextInput (text_input.c:837)
> ==67186==    by 0x4079C5: dlMain (loader.c:205)
> ==67186==    by 0x4079F2: main (loader.c:214)

diff --git a/modules/im/ximcp/imInsClbk.c b/modules/im/ximcp/imInsClbk.c
index 95b379cb..c10e347f 100644
--- a/modules/im/ximcp/imInsClbk.c
+++ b/modules/im/ximcp/imInsClbk.c
@@ -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 );

Does this seem right?


More information about the xorg-devel mailing list