[Spice-devel,6/8] fix 2 X11 related leaks

Submitted by Christophe Fergeau on Aug. 17, 2011, 6:25 p.m.

Details

Message ID 1313580353-3086-7-git-send-email-cfergeau@redhat.com
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Christophe Fergeau Aug. 17, 2011, 6:25 p.m.
---
 client/x11/platform.cpp   |    1 +
 client/x11/red_window.cpp |   11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index 1facf73..2adc160 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -2958,6 +2958,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 d53a92f..cfc10c5 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -1306,16 +1306,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;