summaryrefslogtreecommitdiffstats
path: root/client/x11
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-03-23 17:07:54 +0100
committerHans de Goede <hdegoede@redhat.com>2011-03-23 17:49:57 +0100
commit69067b14e06e2b3043360f7234051e3ad8940f44 (patch)
treedbc96ed9ec8839d55076f3572005530f0c029752 /client/x11
parentb30f8b877ca7b1f27422005310b9e82985d80214 (diff)
downloadspice-69067b14e06e2b3043360f7234051e3ad8940f44.tar.gz
spice-69067b14e06e2b3043360f7234051e3ad8940f44.tar.xz
spice-69067b14e06e2b3043360f7234051e3ad8940f44.zip
spicec-x11: Don't crash on apps sending bad atoms as TARGETS
Some apps (bad xsel, bad!) send invalid Atoms in their TARGETS property, causing spicec to exit because of an XError. This patch makes spicec survive this scenario. For more info on the xsel bug, see: https://bugzilla.redhat.com/show_bug.cgi?id=690214
Diffstat (limited to 'client/x11')
-rw-r--r--client/x11/platform.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index 48d5a52b..9fff947f 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -180,6 +180,18 @@ public:
static DefaultClipboardListener default_clipboard_listener;
static Platform::ClipboardListener* clipboard_listener = &default_clipboard_listener;
+static void handle_x_errors_start(void)
+{
+ handle_x_error = True;
+ x_error_code = 0;
+}
+
+static int handle_x_errors_stop(void)
+{
+ handle_x_error = False;
+ return x_error_code;
+}
+
static const char *atom_name(Atom atom)
{
const char *name;
@@ -188,7 +200,11 @@ static const char *atom_name(Atom atom)
return "None";
XLockDisplay(x_display);
+ handle_x_errors_start();
name = XGetAtomName(x_display, atom);
+ if (handle_x_errors_stop()) {
+ name = "Bad Atom";
+ }
XUnlockDisplay(x_display);
return name;
@@ -317,18 +333,6 @@ Display* XPlatform::get_display()
return x_display;
}
-static void handle_x_errors_start(void)
-{
- handle_x_error = True;
- x_error_code = 0;
-}
-
-static int handle_x_errors_stop(void)
-{
- handle_x_error = False;
- return x_error_code;
-}
-
bool XPlatform::is_x_shm_avail()
{
return x_shm_avail;