[1/5] propsys: Fix memory leak in IPropertyStore::SetValue.

Vincent Povirk madewokherd at gmail.com
Mon Aug 27 17:36:55 CDT 2012


-------------- next part --------------
From b92b957db2c40c0aca600e12bf43ca04bcfd235a Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Mon, 27 Aug 2012 11:39:24 -0500
Subject: [PATCH 1/5] propsys: Fix memory leak in IPropertyStore::SetValue.

---
 dlls/propsys/propstore.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/dlls/propsys/propstore.c b/dlls/propsys/propstore.c
index e438ce3..6d4c99a 100644
--- a/dlls/propsys/propstore.c
+++ b/dlls/propsys/propstore.c
@@ -303,6 +303,7 @@ static HRESULT WINAPI PropertyStore_SetValue(IPropertyStoreCache *iface,
     PropertyStore *This = impl_from_IPropertyStoreCache(iface);
     propstore_value *value;
     HRESULT hr;
+    PROPVARIANT temp;
 
     TRACE("%p,%p,%p\n", iface, key, propvar);
 
@@ -311,7 +312,13 @@ static HRESULT WINAPI PropertyStore_SetValue(IPropertyStoreCache *iface,
     hr = PropertyStore_LookupValue(This, key, 1, &value);
 
     if (SUCCEEDED(hr))
-        hr = PropVariantCopy(&value->propvar, propvar);
+        hr = PropVariantCopy(&temp, propvar);
+
+    if (SUCCEEDED(hr))
+    {
+        PropVariantClear(&value->propvar);
+        value->propvar = temp;
+    }
 
     LeaveCriticalSection(&This->lock);
 
@@ -405,6 +412,7 @@ static HRESULT WINAPI PropertyStore_SetValueAndState(IPropertyStoreCache *iface,
     PropertyStore *This = impl_from_IPropertyStoreCache(iface);
     propstore_value *value;
     HRESULT hr;
+    PROPVARIANT temp;
 
     TRACE("%p,%p,%p,%d\n", iface, key, ppropvar, state);
 
@@ -413,10 +421,14 @@ static HRESULT WINAPI PropertyStore_SetValueAndState(IPropertyStoreCache *iface,
     hr = PropertyStore_LookupValue(This, key, 1, &value);
 
     if (SUCCEEDED(hr))
-        hr = PropVariantCopy(&value->propvar, ppropvar);
+        hr = PropVariantCopy(&temp, ppropvar);
 
     if (SUCCEEDED(hr))
+    {
+        PropVariantClear(&value->propvar);
+        value->propvar = temp;
         value->state = state;
+    }
 
     LeaveCriticalSection(&This->lock);
 
-- 
1.7.9.5


More information about the wine-patches mailing list