While trying to use XIM, I found that calling XGetIMValues with unknown names like: err = XGetIMValues(im, "invalid", &arg, NULL); return address of &arg, instead of the address of name "invalid" as stated in man page (XOpenIM) and Xlib documentation (chapter 13.5.3) : "otherwise, it returns the name of the first argument that could not be obtained." In modules/im/ximcp/imRm.c: _XimGetIMValueData() the function returns p->value instead of p->name . And according to the code in imRm.c, _XimSetIMValueData() has the same problem.
Created attachment 12164 [details] [review] Return p->name instead of p->value (untested) Here is a little patch to change p->value to p->name in _XimSetIMValueData() and _XimGetIMValueData()
My original program does the following: char *name; static const char *invalid = "INVALID"; void *arg = (void *) 0x004c754e; /* "NuL" on i386 arch */ XIMValuesList *imvl = NULL; XIMStyles *ims = NULL; /* retrieve some values, and get an error */ name = XGetIMValues(im, XNQueryIMValuesList, &imvl, XNQueryInputStyle, &ims, invalid, &arg, NULL); if (name != NULL) { /* * name should point to the name * which was not retrieved, eg. "INVALID" */ printf("XGetIMValues() returned: %p '%s'\n" "invalid name: %p '%s'\n" "invalid arg: %p\n", name, name, invalid, invalid, &arg); } And print: XGetIMValues() returned: 0xbf8d1d34 'NuL' invalid name: 0x8048adf 'INVALID' invalid arg: 0xbf8d1d34
(In reply to comment #2) This doesn't compile. Can you an example that compiles so I can check to see if this is still an issue?
Created attachment 41259 [details] Working test case for XGetIMValues() (In reply to comment #3) > This doesn't compile. Can you an example that compiles so I can check to see if > this is still an issue? Here's a complete test case which demonstrate the problem: $ gcc -Wall -Wextra test-XGetIMValues.c -o test-XGetIMValues -lX11 $ ./test-XGetIMValues XLib support current locale Current locale modifier '@im=none' XGetIMValues() returned: 0x7fff220d5628 'NuL' invalid name was : 0x400db8 'INVALID' invalid arg was : 0x7fff220d5628 ERROR: XGetIMValues() returned address of argument instead of its name ERROR: valid function return would be: 0x400db8 'INVALID' As you can see XGetIMValues() returns the argument and not its name. XGetIMValues() man page : The XGetIMValues function presents a variable argument list programming interface for querying properties or features of the specified input method. This function returns NULL if it succeeds; otherwise, it returns the name of the first argument that could not be obtained.
(In reply to comment #4) It was tested on Fedora Core 14 against libX11 1.3.4.
Can you please send your patch to xorg-devel for review? Thanks.
Pushed the fix, thanks.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.