Commit 84a8ae79 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

wbemprox: Fix BSTR leaks caused by incorrect use of SafeArrayPutElement() (Valgrind).

parent f068eb9a
......@@ -700,6 +700,7 @@ SAFEARRAY *to_safearray( const struct array *array, CIMTYPE type )
SafeArrayDestroy( ret );
return NULL;
}
SysFreeString( str );
}
else if (SafeArrayPutElement( ret, &i, ptr ) != S_OK)
{
......@@ -1002,6 +1003,7 @@ HRESULT get_properties( const struct view *view, LONG flags, SAFEARRAY **props )
SafeArrayDestroy( sa );
return E_OUTOFMEMORY;
}
SysFreeString( str );
j++;
}
*props = sa;
......
......@@ -51,6 +51,12 @@ static HRESULT to_bstr_array( BSTR *strings, DWORD count, VARIANT *var )
return S_OK;
}
static void free_bstr_array( BSTR *strings, DWORD count )
{
while (count--)
SysFreeString( *(strings++) );
}
static HRESULT to_i4_array( DWORD *values, DWORD count, VARIANT *var )
{
SAFEARRAY *sa;
......@@ -114,7 +120,11 @@ static HRESULT enum_key( HKEY root, const WCHAR *subkey, VARIANT *names, VARIANT
}
i++;
}
if (hr == S_OK && !res) hr = to_bstr_array( strings, i, names );
if (hr == S_OK && !res)
{
hr = to_bstr_array( strings, i, names );
free_bstr_array( strings, i );
}
set_variant( VT_UI4, res, NULL, retval );
RegCloseKey( hkey );
heap_free( strings );
......@@ -218,6 +228,7 @@ static HRESULT enum_values( HKEY root, const WCHAR *subkey, VARIANT *names, VARI
if (hr == S_OK && !res)
{
hr = to_bstr_array( value_names, i, names );
free_bstr_array( value_names, i );
if (hr == S_OK) hr = to_i4_array( value_types, i, types );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment