diff options
Diffstat (limited to 'CPP/Windows/PropVariant.cpp')
-rwxr-xr-x | CPP/Windows/PropVariant.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/CPP/Windows/PropVariant.cpp b/CPP/Windows/PropVariant.cpp index c2b15744..b95bd242 100755 --- a/CPP/Windows/PropVariant.cpp +++ b/CPP/Windows/PropVariant.cpp @@ -50,6 +50,8 @@ CPropVariant& CPropVariant::operator=(BSTR bstrSrc) return *this; } +static const char *kMemException = "out of memory"; + CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc) { InternalClear(); @@ -58,8 +60,9 @@ CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc) bstrVal = ::SysAllocString(lpszSrc); if (bstrVal == NULL && lpszSrc != NULL) { - vt = VT_ERROR; - scode = E_OUTOFMEMORY; + throw kMemException; + // vt = VT_ERROR; + // scode = E_OUTOFMEMORY; } return *this; } @@ -74,8 +77,9 @@ CPropVariant& CPropVariant::operator=(const char *s) bstrVal = ::SysAllocStringByteLen(0, (UINT)len * sizeof(OLECHAR)); if (bstrVal == NULL) { - vt = VT_ERROR; - scode = E_OUTOFMEMORY; + throw kMemException; + // vt = VT_ERROR; + // scode = E_OUTOFMEMORY; } else { @@ -204,6 +208,8 @@ void CPropVariant::InternalCopy(const PROPVARIANT *pSrc) HRESULT hr = Copy(pSrc); if (FAILED(hr)) { + if (hr == E_OUTOFMEMORY) + throw kMemException; vt = VT_ERROR; scode = hr; } |