From 3dcf92a96bc738f42ffabb44fa169d3a91b6df8d Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sun, 4 Mar 2007 11:32:09 +0000 Subject: [PATCH] Fixed segfaults in xclip.c: [1657964] Copy causes segfault by Jos Dehaes [1664930] Segmentation fault when work with VMWare on remote Windows git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1397 423420c4-83ab-492f-b58f-81f9feb106b5 --- xclip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xclip.c b/xclip.c index 0db9ade..d4450a0 100644 --- a/xclip.c +++ b/xclip.c @@ -289,6 +289,9 @@ xclip_send_data_with_convert(uint8 * source, size_t source_size, Atom target) DEBUG_CLIPBOARD(("xclip_send_data_with_convert: target=%s, size=%u\n", XGetAtomName(g_display, target), (unsigned) source_size)); + if ((!source) || source_size == 0) + return False; + #ifdef USE_UNICODE_CLIPBOARD if (target == format_string_atom || target == format_unicode_atom || target == format_utf8_string_atom) @@ -754,7 +757,7 @@ void xclip_handle_SelectionRequest(XSelectionRequestEvent * event) { unsigned long nitems, bytes_left; - unsigned char *prop_return; + unsigned char *prop_return = NULL; int format, res; Atom type; @@ -796,7 +799,7 @@ xclip_handle_SelectionRequest(XSelectionRequestEvent * event) event->property, 0, 1, True, XA_INTEGER, &type, &format, &nitems, &bytes_left, &prop_return); - if (res != Success) + if (res != Success || (!prop_return)) { DEBUG_CLIPBOARD(("Requested native format but didn't specifiy which.\n")); xclip_refuse_selection(event);