Vincent Povirk : propsys: Fix memory leak in IPropertyStore::SetValue.
Module: wine Branch: master Commit: 0537454eae75efafd60964ad499af40227188a39 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0537454eae75efafd60964ad49... Author: Vincent Povirk <vincent(a)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);
participants (1)
-
Alexandre Julliard