Commit 1445735e authored by Ross Burton's avatar Ross Burton Committed by Ulrich Sibiller

Add missing NULL checks to ICWrap

ICWrap.c dereferences the xim parameter passed in from client code without a NULL check. I have seen mplayer trigger this resulting in a segfault. In this case mplayer had called XOpenIM and NULL was returned which was later passed into XCreateIC. Patch originally by Drew Moseley <drew_moseley@mentor.com>. Signed-off-by: 's avatarRoss Burton <ross.burton@intel.com> Reviewed-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent 39dd37d5
...@@ -169,7 +169,7 @@ XSetIMValues(XIM im, ...) ...@@ -169,7 +169,7 @@ XSetIMValues(XIM im, ...)
va_list var; va_list var;
int total_count; int total_count;
XIMArg *args; XIMArg *args;
char *ret; char *ret = NULL;
/* /*
* so count the stuff dangling here * so count the stuff dangling here
...@@ -185,7 +185,8 @@ XSetIMValues(XIM im, ...) ...@@ -185,7 +185,8 @@ XSetIMValues(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args); _XIMVaToNestedList(var, total_count, &args);
va_end(var); va_end(var);
ret = (*im->methods->set_values) (im, args); if (im && im->methods)
ret = (*im->methods->set_values) (im, args);
Xfree(args); Xfree(args);
return ret; return ret;
} }
...@@ -196,7 +197,7 @@ XGetIMValues(XIM im, ...) ...@@ -196,7 +197,7 @@ XGetIMValues(XIM im, ...)
va_list var; va_list var;
int total_count; int total_count;
XIMArg *args; XIMArg *args;
char *ret; char *ret = NULL;
/* /*
* so count the stuff dangling here * so count the stuff dangling here
...@@ -212,7 +213,8 @@ XGetIMValues(XIM im, ...) ...@@ -212,7 +213,8 @@ XGetIMValues(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args); _XIMVaToNestedList(var, total_count, &args);
va_end(var); va_end(var);
ret = (*im->methods->get_values) (im, args); if (im && im->methods)
ret = (*im->methods->get_values) (im, args);
Xfree(args); Xfree(args);
return ret; return ret;
} }
...@@ -228,7 +230,7 @@ XCreateIC(XIM im, ...) ...@@ -228,7 +230,7 @@ XCreateIC(XIM im, ...)
va_list var; va_list var;
int total_count; int total_count;
XIMArg *args; XIMArg *args;
XIC ic; XIC ic = NULL;
/* /*
* so count the stuff dangling here * so count the stuff dangling here
...@@ -244,7 +246,8 @@ XCreateIC(XIM im, ...) ...@@ -244,7 +246,8 @@ XCreateIC(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args); _XIMVaToNestedList(var, total_count, &args);
va_end(var); va_end(var);
ic = (XIC) (*im->methods->create_ic) (im, args); if (im && im->methods)
ic = (XIC) (*im->methods->create_ic) (im, args);
Xfree(args); Xfree(args);
if (ic) { if (ic) {
ic->core.next = im->core.ic_chain; ic->core.next = im->core.ic_chain;
......
Markdown is supported
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