summaryrefslogtreecommitdiffstats
path: root/client/x11/platform.cpp
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:11:25 +0100
commit4020e243455641cc21af41e07ab63e19e60e08e9 (patch)
treef08d2ffa020faca0b99a53d46c00d4b16eef53d4 /client/x11/platform.cpp
parenta81fbdd91c242c9f2ff2cd1edcb5e16dca59d570 (diff)
downloadspice-4020e243455641cc21af41e07ab63e19e60e08e9.tar.gz
spice-4020e243455641cc21af41e07ab63e19e60e08e9.tar.xz
spice-4020e243455641cc21af41e07ab63e19e60e08e9.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/platform.cpp')
-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;