XCreateIC() leaks name and class strings
Submitted by Andrew Church
Assigned to Xorg Project Team
Description
In libX11-1.6.2, when creating an input context, the name and class strings passed with XNResourceName and XNResourceClass are copied, but the copies are not freed when XDestroyIC() is called on the resulting input context:
main() {
/* ... */
XIC ic = XCreateIC(x11_im,
XNClientWindow, window,
XNFocusWindow, window,
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNResourceName, "foobar", // Leaked.
XNResourceClass, "foobar", // Leaked.
NULL);
XDestroyIC(ic);
/* ... */
}
$ valgrind --leak-check=full ./test
[...]
==8402== 14 bytes in 2 blocks are definitely lost in loss record 13 of 94
==8402== at 0x4C2B960: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8402== by 0x79392D1: strdup (in /lib64/libc-2.20.so)
==8402== by 0x69F22E6: ??? (in /usr/lib64/libX11.so.6.3.0)
==8402== by 0x69F3114: _XimSetICValueData (in /usr/lib64/libX11.so.6.3.0)
==8402== by 0x69EE628: _XimLocalCreateIC (in /usr/lib64/libX11.so.6.3.0)
==8402== by 0x69D3AB4: XCreateIC (in /usr/lib64/libX11.so.6.3.0)
Set to severity "minor" since the leak size is small and most programs will probably not call XCreateIC() and XDestroyIC() over and over.
Edited by Alan Coopersmith