Vincent Povirk : propsys: Fix memory leak in IPropertyStore::SetValue.

Alexandre Julliard julliard at winehq.org
Tue Aug 28 14:44:39 CDT 2012


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Mon Aug 27 11:39:24 2012 -0500

propsys: Fix memory leak in IPropertyStore::SetValue.

---

 dlls/propsys/propstore.c |   16 ++++++++++++++--
 1 files 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);
 




More information about the wine-cvs mailing list