Juan Lang : rsaenh: Fix memory leak reading stored keys.

Alexandre Julliard julliard at winehq.org
Thu Dec 10 10:00:58 CST 2009


Module: wine
Branch: master
Commit: f9a475c808b3bbc4980f3225dfa2a7397df9f4db
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f9a475c808b3bbc4980f3225dfa2a7397df9f4db

Author: Juan Lang <juan.lang at gmail.com>
Date:   Wed Dec  9 14:43:05 2009 -0800

rsaenh: Fix memory leak reading stored keys.

---

 dlls/rsaenh/rsaenh.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c
index 5c2b8b0..665bc40 100644
--- a/dlls/rsaenh/rsaenh.c
+++ b/dlls/rsaenh/rsaenh.c
@@ -1380,12 +1380,18 @@ static HCRYPTPROV read_key_container(PCHAR pszContainerName, DWORD dwFlags, cons
                            (OBJECTHDR**)&pKeyContainer))
             return (HCRYPTPROV)INVALID_HANDLE_VALUE;
     
+        /* read_key_value calls import_key, which calls import_private_key,
+         * which implicitly installs the key value into the appropriate key
+         * container key.  Thus the ref count is incremented twice, once for
+         * the output key value, and once for the implicit install, and needs
+         * to be decremented to balance the two.
+         */
         if (read_key_value(hKeyContainer, hKey, AT_KEYEXCHANGE,
             dwProtectFlags, &hCryptKey))
-            pKeyContainer->hKeyExchangeKeyPair = hCryptKey;
+            release_handle(&handle_table, hCryptKey, RSAENH_MAGIC_KEY);
         if (read_key_value(hKeyContainer, hKey, AT_SIGNATURE,
             dwProtectFlags, &hCryptKey))
-            pKeyContainer->hSignatureKeyPair = hCryptKey;
+            release_handle(&handle_table, hCryptKey, RSAENH_MAGIC_KEY);
     }
 
     return hKeyContainer;




More information about the wine-cvs mailing list