mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 22:50:43 +00:00
wbemprox: Fix BSTR leaks caused by incorrect use of SafeArrayPutElement() (Valgrind).
This commit is contained in:
parent
f068eb9acd
commit
84a8ae79d2
@ -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 );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user