[Spice-commits] 3 commits - client/red_channel.cpp client/red_client.cpp client/x11

Christophe Fergau teuf at kemper.freedesktop.org
Mon Aug 15 02:23:24 PDT 2011


 client/red_channel.cpp    |   10 +++++++---
 client/red_client.cpp     |    1 +
 client/x11/platform.cpp   |    1 +
 client/x11/red_window.cpp |   11 +++++++----
 4 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 0d4bd55042391d7cbbc9f21725aba02e50174d5b
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Aug 12 12:05:47 2011 +0200

    fix 2 X11 related leaks

diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index fe98eae..09ca61d 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -2961,6 +2961,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;
commit d7d0a3a98ef24a7be944c54c278f04c59a60974b
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Aug 12 12:05:22 2011 +0200

    channel: fix EVP_PKEY leak

diff --git a/client/red_channel.cpp b/client/red_channel.cpp
index 5f8bd25..8632600 100644
--- a/client/red_channel.cpp
+++ b/client/red_channel.cpp
@@ -71,10 +71,7 @@ void RedChannelBase::link(uint32_t connection_id, const std::string& password,
     uint32_t link_res;
     uint32_t i;
 
-    EVP_PKEY *pubkey;
-    int nRSASize;
     BIO *bioKey;
-    RSA *rsa;
     uint8_t *buffer, *p;
     uint32_t expected_major;
 
@@ -171,6 +168,10 @@ void RedChannelBase::link(uint32_t connection_id, const std::string& password,
 
     bioKey = BIO_new(BIO_s_mem());
     if (bioKey != NULL) {
+        EVP_PKEY *pubkey;
+        int nRSASize;
+        RSA *rsa;
+
         BIO_write(bioKey, reply->pub_key, SPICE_TICKET_PUBKEY_BYTES);
         pubkey = d2i_PUBKEY_bio(bioKey, NULL);
         rsa = pubkey->pkey.rsa;
@@ -186,10 +187,13 @@ void RedChannelBase::link(uint32_t connection_id, const std::string& password,
                                rsa, RSA_PKCS1_OAEP_PADDING) > 0) {
             send((uint8_t*)bufEncrypted.get(), nRSASize);
         } else {
+            EVP_PKEY_free(pubkey);
+            BIO_free(bioKey);
             THROW("could not encrypt password");
         }
 
         memset(bufEncrypted.get(), 0, nRSASize);
+        EVP_PKEY_free(pubkey);
     } else {
         THROW("Could not initiate BIO");
     }
commit 855f2ed2ac6a67e88d6f6626641af508b887cd4b
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Aug 12 10:32:56 2011 +0200

    always set VDAgentDisplayConfig::depth
    
    Even if VDAgentDisplayConfig::depth will be unused if the
    VD_AGENT_DISPLAY_CONFIG_FLAG_SET_COLOR_DEPTH isn't set, it's
    better to initialize it anyway to avoid warnings from valgrind.

diff --git a/client/red_client.cpp b/client/red_client.cpp
index e084759..efd9feb 100644
--- a/client/red_client.cpp
+++ b/client/red_client.cpp
@@ -740,6 +740,7 @@ void RedClient::send_agent_display_config()
         spice_marshaller_reserve_space(message->marshaller(), sizeof(VDAgentDisplayConfig));
 
     disp_config->flags = 0;
+    disp_config->depth = 0;
     if (_display_setting._disable_wallpaper) {
         disp_config->flags |= VD_AGENT_DISPLAY_CONFIG_FLAG_DISABLE_WALLPAPER;
     }


More information about the Spice-commits mailing list