diff options
author | Keith Packard <keithp@keithp.com> | 2020-11-17 13:15:18 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2020-11-17 14:42:25 -0800 |
commit | a3c0b5dbd6b12ae64bc78b11795647a7f6df0c7a (patch) | |
tree | 361ab4dbc13fa9fed070df25e22967df53904f89 /modules | |
parent | 960e2e0cfac12c3477c672d0d40818a0dc74aca5 (diff) |
Copy locale modifiers when creating XimInstCallback [v2]
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 <zeccav@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
v2:
Remove incorrect 'else' token found by @alanc
Diffstat (limited to 'modules')
-rw-r--r-- | modules/im/ximcp/imInsClbk.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/im/ximcp/imInsClbk.c b/modules/im/ximcp/imInsClbk.c index 961aabaa..95b379cb 100644 --- a/modules/im/ximcp/imInsClbk.c +++ b/modules/im/ximcp/imInsClbk.c @@ -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 ); + } + } 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 ); |