From 7d7224d8543e85e3a34a1cddf99f3eac9aa9050b Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 12 Apr 2011 21:27:45 -0700 Subject: Replace Xmalloc+bzero pairs with Xcalloc calls Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imTrX.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'nx-X11/lib/X11/imTrX.c') diff --git a/nx-X11/lib/X11/imTrX.c b/nx-X11/lib/X11/imTrX.c index 2b5455f1b..6b757cee5 100644 --- a/nx-X11/lib/X11/imTrX.c +++ b/nx-X11/lib/X11/imTrX.c @@ -487,9 +487,8 @@ _XimXConf(Xim im, char *address) { XSpecRec *spec; - if (!(spec = (XSpecRec *)Xmalloc(sizeof(XSpecRec)))) + if (!(spec = Xcalloc(1, sizeof(XSpecRec)))) return False; - bzero(spec, sizeof(XSpecRec)); spec->improtocolid = XInternAtom(im->core.display, _XIM_PROTOCOL, False); spec->imconnectid = XInternAtom(im->core.display, _XIM_XCONNECT, False); -- cgit v1.2.3 From 89dc7ccfbcaf45db6ca8d5fa548568b7fb7529de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Mon, 31 Jan 2011 14:02:14 +0200 Subject: ximcp/imTrX: Handle failing XGetWindowProperty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Checked return value of XGetWindowProperty and return false if it fails. Return value of "XGetWindowProperty(im->core.display, spec->lib_connect_wid, prop, 0L, (length + bytes_after_ret + 3UL) / 4UL, 1, 0UL, &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret)" is not checked Reviewed-by: Alan Coopersmith Signed-off-by: Erkki Seppälä Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imTrX.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'nx-X11/lib/X11/imTrX.c') diff --git a/nx-X11/lib/X11/imTrX.c b/nx-X11/lib/X11/imTrX.c index 6b757cee5..b81c173c5 100644 --- a/nx-X11/lib/X11/imTrX.c +++ b/nx-X11/lib/X11/imTrX.c @@ -377,14 +377,19 @@ _XimXGetReadData( *ret_len = (int)nitems; if (bytes_after_ret > 0) { XFree(prop_ret); - XGetWindowProperty(im->core.display, - spec->lib_connect_wid, prop, 0L, - ((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType, - &type_ret, &format_ret, &nitems, &bytes_after_ret, - &prop_ret); - XChangeProperty(im->core.display, spec->lib_connect_wid, prop, - XA_STRING, 8, PropModePrepend, &prop_ret[length], - (nitems - length)); + if (XGetWindowProperty(im->core.display, + spec->lib_connect_wid, prop, 0L, + ((length + bytes_after_ret + 3)/ 4), + True, AnyPropertyType, + &type_ret, &format_ret, &nitems, + &bytes_after_ret, + &prop_ret) == Success) { + XChangeProperty(im->core.display, spec->lib_connect_wid, prop, + XA_STRING, 8, PropModePrepend, &prop_ret[length], + (nitems - length)); + } else { + return False; + } } } else { (void)memcpy(buf, prop_ret, buf_len); @@ -393,10 +398,14 @@ _XimXGetReadData( if (bytes_after_ret > 0) { XFree(prop_ret); - XGetWindowProperty(im->core.display, - spec->lib_connect_wid, prop, 0L, - ((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType, - &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret); + if (XGetWindowProperty(im->core.display, + spec->lib_connect_wid, prop, 0L, + ((length + bytes_after_ret + 3)/ 4), + True, AnyPropertyType, + &type_ret, &format_ret, &nitems, + &bytes_after_ret, &prop_ret) != Success) { + return False; + } } XChangeProperty(im->core.display, spec->lib_connect_wid, prop, XA_STRING, 8, PropModePrepend, &prop_ret[buf_len], len); -- cgit v1.2.3 From 11d6dac92b6c3c3f62d49817809ce8c6a61c9293 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Mon, 22 Oct 2012 13:54:11 -0500 Subject: XIM: remove Private and Public macros Private is a struct member name in mingw-w64 , causing this useless define in a private header to break the build. Signed-off-by: Yaakov Selkowitz Reviewed-by: Jon TURNEY Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imTrX.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'nx-X11/lib/X11/imTrX.c') diff --git a/nx-X11/lib/X11/imTrX.c b/nx-X11/lib/X11/imTrX.c index b81c173c5..dfe915f9d 100644 --- a/nx-X11/lib/X11/imTrX.c +++ b/nx-X11/lib/X11/imTrX.c @@ -60,7 +60,7 @@ PERFORMANCE OF THIS SOFTWARE. #include "XimTrInt.h" #include "XimTrX.h" -Private Bool +static Bool _XimXRegisterDispatcher( Xim im, Bool (*callback)( @@ -81,7 +81,7 @@ _XimXRegisterDispatcher( return True; } -Private void +static void _XimXFreeIntrCallback( Xim im) { @@ -96,7 +96,7 @@ _XimXFreeIntrCallback( return; } -Private Bool +static Bool _XimXCallDispatcher(Xim im, INT16 len, XPointer data) { register XIntrCallbackRec *rec; @@ -109,7 +109,7 @@ _XimXCallDispatcher(Xim im, INT16 len, XPointer data) return False; } -Private Bool +static Bool _XimXFilterWaitEvent( Display *d, Window w, @@ -137,7 +137,7 @@ _XimXFilterWaitEvent( return ret; } -Private Bool +static Bool _CheckConnect( Display *display, XEvent *event, @@ -153,7 +153,7 @@ _CheckConnect( return False; } -Private Bool +static Bool _XimXConnect(Xim im) { XEvent event; @@ -224,7 +224,7 @@ _XimXConnect(Xim im) return True; } -Private Bool +static Bool _XimXShutdown(Xim im) { XSpecRec *spec = (XSpecRec *)im->private.proto.spec; @@ -244,7 +244,7 @@ _XimXShutdown(Xim im) return True; } -Private char * +static char * _NewAtom( char *atomName) { @@ -255,7 +255,7 @@ _NewAtom( return atomName; } -Private Bool +static Bool _XimXWrite(Xim im, INT16 len, XPointer data) { Atom atom; @@ -316,7 +316,7 @@ _XimXWrite(Xim im, INT16 len, XPointer data) return True; } -Private Bool +static Bool _XimXGetReadData( Xim im, char *buf, @@ -440,7 +440,7 @@ _XimXGetReadData( return True; } -Private Bool +static Bool _CheckCMEvent( Display *display, XEvent *event, @@ -461,7 +461,7 @@ _CheckCMEvent( return False; } -Private Bool +static Bool _XimXRead(Xim im, XPointer recv_buf, int buf_len, int *ret_len) { XEvent *ev; @@ -484,14 +484,14 @@ _XimXRead(Xim im, XPointer recv_buf, int buf_len, int *ret_len) return True; } -Private void +static void _XimXFlush(Xim im) { XFlush(im->core.display); return; } -Public Bool +Bool _XimXConf(Xim im, char *address) { XSpecRec *spec; -- cgit v1.2.3 From bd43a06402b7499a74de0d4fb5ef8330b490b38f Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 3 Sep 2010 23:11:53 -0700 Subject: Sun's copyrights are now owned by Oracle Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imTrX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/lib/X11/imTrX.c') diff --git a/nx-X11/lib/X11/imTrX.c b/nx-X11/lib/X11/imTrX.c index dfe915f9d..6b1d61f2d 100644 --- a/nx-X11/lib/X11/imTrX.c +++ b/nx-X11/lib/X11/imTrX.c @@ -1,5 +1,5 @@ /* - * Copyright 1992 Sun Microsystems, Inc. All rights reserved. + * Copyright 1992 Oracle and/or its affiliates. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), -- cgit v1.2.3 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/imTrX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/lib/X11/imTrX.c') diff --git a/nx-X11/lib/X11/imTrX.c b/nx-X11/lib/X11/imTrX.c index 6b1d61f2d..148b7fc90 100644 --- a/nx-X11/lib/X11/imTrX.c +++ b/nx-X11/lib/X11/imTrX.c @@ -71,7 +71,7 @@ _XimXRegisterDispatcher( XIntrCallbackPtr rec; XSpecRec *spec = (XSpecRec *)im->private.proto.spec; - if (!(rec = (XIntrCallbackPtr)Xmalloc(sizeof(XIntrCallbackRec)))) + if (!(rec = Xmalloc(sizeof(XIntrCallbackRec)))) return False; rec->func = callback; -- cgit v1.2.3