Commit 901fec1a authored by Keith Packard's avatar Keith Packard
Browse files

Copy locale modifiers when creating XimInstCallback



Locale modifiers may be freed whenever XSetLocaleModifiers gets
called, even if the locale hasn't changed. This means that we cannot
save a pointer to those modifiers in the XimInstCallback record and
must, instead, make a copy of them instead.

This fixes a problem uncovered when running wish under libasan as
follows (on current Debian unstable):

	$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.6 wish
Reported-by: Vittorio Zecca's avatarVittorio Zecca <zeccav@gmail.com>
Signed-off-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent d84c7a0f
Pipeline #230317 passed with stages
in 10 minutes and 8 seconds
......@@ -162,6 +162,7 @@ _XimRegisterIMInstantiateCallback(
{
XimInstCallback icb, tmp;
XIM xim;
char *modifiers = NULL;
Window root;
XWindowAttributes attr;
......@@ -171,11 +172,18 @@ _XimRegisterIMInstantiateCallback(
icb = Xmalloc(sizeof(XimInstCallbackRec));
if( !icb )
return( False );
if (lcd->core->modifiers) {
modifiers = strdup(lcd->core->modifiers);
if (!modifiers) {
Xfree(icb);
return( False );
}
} else
icb->call = icb->destroy = False;
icb->display = display;
icb->lcd = lcd;
MakeLocale( lcd, icb->name );
icb->modifiers = lcd->core->modifiers; /* XXXXX */
icb->modifiers = modifiers;
icb->rdb = rdb;
icb->res_name = res_name;
icb->res_class = res_class;
......@@ -258,6 +266,7 @@ _XimUnRegisterIMInstantiateCallback(
else
picb->next = icb->next;
_XCloseLC( icb->lcd );
XFree( icb->modifiers );
XFree( icb );
}
return( True );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment