[Spice-devel] [PATCH 3/3] fix 2 X11 related leaks

Christophe Fergeau cfergeau at redhat.com
Fri Aug 12 09:03:32 PDT 2011


---
 client/x11/platform.cpp   |    1 +
 client/x11/red_window.cpp |   11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index 609898a..2b2dfa8 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -2967,6 +2967,7 @@ static unsigned int get_modifier_mask(KeySym modifier)
     XModifierKeymap* map = XGetModifierMapping(x_display);
     KeyCode keycode = XKeysymToKeycode(x_display, modifier);
     if (keycode == NoSymbol) {
+        XFreeModifiermap(map);
         return 0;
     }
 
diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index 9f4da60..2e98ae2 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -1309,16 +1309,19 @@ void RedWindow_p::move_to_current_desktop()
     unsigned long nitems_return;
     unsigned char *prop_return;
     long desktop = ~long(0);
+    int status;
 
     XLockDisplay(x_display);
-    if (XGetWindowProperty(x_display, root, wm_current_desktop, 0, 1, False, AnyPropertyType,
-                           &actual_type_return, &actual_format_return, &nitems_return,
-                           &bytes_after_return, &prop_return) == Success &&
-                                         actual_type_return != None && actual_format_return == 32) {
+    status = XGetWindowProperty(x_display, root, wm_current_desktop, 0, 1, False, AnyPropertyType,
+                                &actual_type_return, &actual_format_return, &nitems_return,
+                                &bytes_after_return, &prop_return);
+    if ((status  == Success) && (actual_type_return != None) && (actual_format_return == 32)) {
         desktop = *(uint32_t *)prop_return;
     } else {
         DBG(0, "get current desktop failed");
     }
+    if (status == Success)
+        XFree(prop_return);
     XUnlockDisplay(x_display);
 
     XEvent xevent;
-- 
1.7.6



More information about the Spice-devel mailing list