From 33e2ac3da4ead3efd519232195d90ca0a6592b21 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 14 Jun 2019 14:51:26 +0200 Subject: [PATCH] Address code analysis warnings Signed-off-by: Simon Rozman --- include/WinStd/COM.h | 15 ++++++++------- include/WinStd/Common.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/WinStd/COM.h b/include/WinStd/COM.h index 7e243d77..fd809c70 100644 --- a/include/WinStd/COM.h +++ b/include/WinStd/COM.h @@ -345,6 +345,7 @@ namespace winstd /// /// Moves VARIANT from another /// + #pragma warning(suppress: 26495) // vt member is initialized as a result of memcpy() inline variant(_Inout_ VARIANT&& varSrc) { memcpy(this, &varSrc, sizeof(VARIANT)); @@ -532,13 +533,13 @@ namespace winstd assert(pSrc != NULL); LPSAFEARRAY pCopy; - HRESULT hRes = SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); - if (SUCCEEDED(hRes)) { - SafeArrayGetVartype((LPSAFEARRAY)pSrc, &vt); - vt |= VT_ARRAY; - parray = pCopy; - } else - assert(0); + HRESULT hr = SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); + if (FAILED(hr)) + throw winstd::com_runtime_error(hr, "SafeArrayCopy failed."); + + SafeArrayGetVartype((LPSAFEARRAY)pSrc, &vt); + vt |= VT_ARRAY; + parray = pCopy; } /// diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index 00eea5e8..69a2192a 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -496,7 +496,7 @@ namespace winstd /// /// Delete a pointer /// - void operator()(_Ty *_Ptr) const + void operator()(_Frees_ptr_opt_ _Ty *_Ptr) const { LocalFree(_Ptr); }