COM: Allow safearray_accessor with NULL SAFEARRAY
This allows accessor to be used in the parent scope before checking SAFEARRAY for NULL. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
e1d4e03831
commit
01adb60ded
@ -1104,9 +1104,13 @@ namespace winstd
|
|||||||
///
|
///
|
||||||
safearray_accessor(_In_ SAFEARRAY* psa) : m_sa(psa)
|
safearray_accessor(_In_ SAFEARRAY* psa) : m_sa(psa)
|
||||||
{
|
{
|
||||||
HRESULT hr = SafeArrayAccessData(psa, (void HUGEP**) & m_data);
|
if (psa) {
|
||||||
if (FAILED(hr))
|
HRESULT hr = SafeArrayAccessData(psa, (void HUGEP**) & m_data);
|
||||||
throw com_runtime_error(hr, "SafeArrayAccessData failed");
|
if (FAILED(hr))
|
||||||
|
throw com_runtime_error(hr, "SafeArrayAccessData failed");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_data = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -1116,7 +1120,8 @@ namespace winstd
|
|||||||
///
|
///
|
||||||
virtual ~safearray_accessor()
|
virtual ~safearray_accessor()
|
||||||
{
|
{
|
||||||
SafeArrayUnaccessData(m_sa);
|
if (m_sa)
|
||||||
|
SafeArrayUnaccessData(m_sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user