From 8510949a60e448838e389f9eb0636a928232c9da Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang@gmail.com>
Date: Mon, 2 Nov 2009 10:27:25 -0800
Subject: [PATCH] Fix a memory leak querying a message object

---
 dlls/crypt32/object.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c
index c337784..3d18c50 100644
--- a/dlls/crypt32/object.c
+++ b/dlls/crypt32/object.c
@@ -599,11 +599,13 @@ static BOOL CRYPT_QueryMessageObject(DWORD dwObjectType, const void *pvObject,
     {
         if (pdwFormatType)
             *pdwFormatType = formatType;
-        if (phMsg)
-            *phMsg = msg;
         if (phCertStore)
             *phCertStore = CertOpenStore(CERT_STORE_PROV_MSG, encodingType, 0,
              0, msg);
+        if (phMsg)
+            *phMsg = msg;
+        else
+            CryptMsgClose(msg);
     }
     if (blob == &fileBlob)
         CryptMemFree(blob->pbData);
-- 
1.6.0.6

