From c161df4fee61819a28089682963cc2e721ca22c8 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 10 Aug 2013 23:51:08 -0700 Subject: Remove even more casts of return values from Xmalloc/Xrealloc Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/ICWrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/lib/X11/ICWrap.c') diff --git a/nx-X11/lib/X11/ICWrap.c b/nx-X11/lib/X11/ICWrap.c index 1eacfa5f1..8584e36a7 100644 --- a/nx-X11/lib/X11/ICWrap.c +++ b/nx-X11/lib/X11/ICWrap.c @@ -128,7 +128,7 @@ _XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return) return; } - args = (XIMArg *)Xmalloc((unsigned)(max_count + 1) * sizeof(XIMArg)); + args = Xmalloc((unsigned)(max_count + 1) * sizeof(XIMArg)); *args_return = args; if (!args) return; -- cgit v1.2.3 From d33cf0446fa6bd838f0020da2fd4a0884c2bc5ef Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 10 Aug 2013 23:57:55 -0700 Subject: Don't cast sizeof() results to unsigned when passing to Xmalloc/Xcalloc sizeof() returns size_t, malloc() & calloc() expect sizes in size_t, don't strip down to unsigned int and re-expand unnecessarily. Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/ICWrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/lib/X11/ICWrap.c') diff --git a/nx-X11/lib/X11/ICWrap.c b/nx-X11/lib/X11/ICWrap.c index 8584e36a7..dadc8f541 100644 --- a/nx-X11/lib/X11/ICWrap.c +++ b/nx-X11/lib/X11/ICWrap.c @@ -128,7 +128,7 @@ _XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return) return; } - args = Xmalloc((unsigned)(max_count + 1) * sizeof(XIMArg)); + args = Xmalloc(((unsigned)max_count + 1) * sizeof(XIMArg)); *args_return = args; if (!args) return; -- cgit v1.2.3 From 26256188b498e122e21ce0e05521dfc58f8b60a5 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 11 Aug 2013 00:07:33 -0700 Subject: Remove unnecessary casts of pointers to (char *) in calls to Xfree() Left one cast behind that is necessary to change from const char * to char * in nx-X11/lib/X11/lcCharSet.c. Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/ICWrap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'nx-X11/lib/X11/ICWrap.c') diff --git a/nx-X11/lib/X11/ICWrap.c b/nx-X11/lib/X11/ICWrap.c index dadc8f541..2a1d0d670 100644 --- a/nx-X11/lib/X11/ICWrap.c +++ b/nx-X11/lib/X11/ICWrap.c @@ -186,7 +186,7 @@ XSetIMValues(XIM im, ...) va_end(var); ret = (*im->methods->set_values) (im, args); - if (args) Xfree((char *)args); + if (args) Xfree(args); return ret; } @@ -213,7 +213,7 @@ XGetIMValues(XIM im, ...) va_end(var); ret = (*im->methods->get_values) (im, args); - if (args) Xfree((char *)args); + if (args) Xfree(args); return ret; } @@ -245,7 +245,7 @@ XCreateIC(XIM im, ...) va_end(var); ic = (XIC) (*im->methods->create_ic) (im, args); - if (args) Xfree((char *)args); + if (args) Xfree(args); if (ic) { ic->core.next = im->core.ic_chain; im->core.ic_chain = ic; @@ -271,7 +271,7 @@ XDestroyIC(XIC ic) } } } - Xfree ((char *) ic); + Xfree (ic); } char * @@ -300,7 +300,7 @@ XGetICValues(XIC ic, ...) va_end(var); ret = (*ic->methods->get_values) (ic, args); - if (args) Xfree((char *)args); + if (args) Xfree(args); return ret; } @@ -330,7 +330,7 @@ XSetICValues(XIC ic, ...) va_end(var); ret = (*ic->methods->set_values) (ic, args); - if (args) Xfree((char *)args); + if (args) Xfree(args); return ret; } -- cgit v1.2.3 From a98260726b8f878e72223899e21ad87882389e2d Mon Sep 17 00:00:00 2001 From: walter harms Date: Sat, 7 Jun 2014 15:17:27 +0200 Subject: libX11: rm redundante NULL checks This patch removes the last remaining NULL checks for Xfree() Signed-off-by: Harms Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/ICWrap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'nx-X11/lib/X11/ICWrap.c') diff --git a/nx-X11/lib/X11/ICWrap.c b/nx-X11/lib/X11/ICWrap.c index 2a1d0d670..8c1b4a01c 100644 --- a/nx-X11/lib/X11/ICWrap.c +++ b/nx-X11/lib/X11/ICWrap.c @@ -186,7 +186,7 @@ XSetIMValues(XIM im, ...) va_end(var); ret = (*im->methods->set_values) (im, args); - if (args) Xfree(args); + Xfree(args); return ret; } @@ -213,7 +213,7 @@ XGetIMValues(XIM im, ...) va_end(var); ret = (*im->methods->get_values) (im, args); - if (args) Xfree(args); + Xfree(args); return ret; } @@ -245,7 +245,7 @@ XCreateIC(XIM im, ...) va_end(var); ic = (XIC) (*im->methods->create_ic) (im, args); - if (args) Xfree(args); + Xfree(args); if (ic) { ic->core.next = im->core.ic_chain; im->core.ic_chain = ic; @@ -300,7 +300,7 @@ XGetICValues(XIC ic, ...) va_end(var); ret = (*ic->methods->get_values) (ic, args); - if (args) Xfree(args); + Xfree(args); return ret; } @@ -330,7 +330,7 @@ XSetICValues(XIC ic, ...) va_end(var); ret = (*ic->methods->set_values) (ic, args); - if (args) Xfree(args); + Xfree(args); return ret; } -- cgit v1.2.3 From 1445735ef8fb669de0b96f01939c77ce285b5f4c Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Mon, 18 May 2015 14:49:01 +0100 Subject: 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 . Signed-off-by: Ross Burton Reviewed-by: Alan Coopersmith Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/ICWrap.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'nx-X11/lib/X11/ICWrap.c') diff --git a/nx-X11/lib/X11/ICWrap.c b/nx-X11/lib/X11/ICWrap.c index 8c1b4a01c..69f080d87 100644 --- a/nx-X11/lib/X11/ICWrap.c +++ b/nx-X11/lib/X11/ICWrap.c @@ -169,7 +169,7 @@ XSetIMValues(XIM im, ...) va_list var; int total_count; XIMArg *args; - char *ret; + char *ret = NULL; /* * so count the stuff dangling here @@ -185,7 +185,8 @@ XSetIMValues(XIM im, ...) _XIMVaToNestedList(var, total_count, &args); va_end(var); - ret = (*im->methods->set_values) (im, args); + if (im && im->methods) + ret = (*im->methods->set_values) (im, args); Xfree(args); return ret; } @@ -196,7 +197,7 @@ XGetIMValues(XIM im, ...) va_list var; int total_count; XIMArg *args; - char *ret; + char *ret = NULL; /* * so count the stuff dangling here @@ -212,7 +213,8 @@ XGetIMValues(XIM im, ...) _XIMVaToNestedList(var, total_count, &args); va_end(var); - ret = (*im->methods->get_values) (im, args); + if (im && im->methods) + ret = (*im->methods->get_values) (im, args); Xfree(args); return ret; } @@ -228,7 +230,7 @@ XCreateIC(XIM im, ...) va_list var; int total_count; XIMArg *args; - XIC ic; + XIC ic = NULL; /* * so count the stuff dangling here @@ -244,7 +246,8 @@ XCreateIC(XIM im, ...) _XIMVaToNestedList(var, total_count, &args); 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); if (ic) { ic->core.next = im->core.ic_chain; -- cgit v1.2.3