summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-10-20 14:51:58 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-10-26 20:50:05 +0200
commitd5a9b1fe0a3452cf3e78535a98f3caa28648ab10 (patch)
tree2fa4b62126cde7ead46071f2716250bf214257df
parent6b505e004fce2d6fa60691b8cd05fdb23cb33024 (diff)
V745 A 'wchar_t *' type string is incorrectly converted to 'BSTR' type string. Consider using 'SysAllocString' function. V560 A part of conditional expression is always false: !ppdispParent. V595 The 'm_pIParent' pointer was utilized before it was verified against nullptr. Check lines: 673, 675. V745 A 'wchar_t *' type string is incorrectly converted to 'BSTR' type string. Consider using 'SysAllocString' function. V530 The return value of function 'SysAllocString' is required to be utilized. V1032 The pointer '& pChildXAcc' is cast to a more strictly aligned pointer type. V512 A call of the 'GetUNOInterface' function will lead to overflow of the buffer '& pChildXAcc'. V547 Expression 'pSeq' is always true. V547 Expression 'pChild' is always true. V512 A call of the 'GetUNOInterface' function will lead to overflow of the buffer '& pTempUNO'. V1032 The pointer '& pTempUNO' is cast to a more strictly aligned pointer type. V716 Suspicious type conversion in return statement: returned HRESULT, but function actually returns BOOL. Change-Id: I2185992dad0127144416783e25476d05c0365b74 Reviewed-on: https://gerrit.libreoffice.org/62077 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--winaccessibility/source/UAccCOM/MAccessible.cxx52
-rw-r--r--winaccessibility/source/UAccCOM/MAccessible.h8
2 files changed, 32 insertions, 28 deletions
diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx
index 63ad985401d9..279fd6ad1e00 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.cxx
+++ b/winaccessibility/source/UAccCOM/MAccessible.cxx
@@ -194,23 +194,19 @@ CMAccessible::~CMAccessible()
if(m_pszName!=nullptr)
{
SAFE_SYSFREESTRING(m_pszName);
- m_pszName=nullptr;
}
if(m_pszValue!=nullptr)
{
SAFE_SYSFREESTRING(m_pszValue);
- m_pszValue=nullptr;
}
if(m_pszDescription!=nullptr)
{
SAFE_SYSFREESTRING(m_pszDescription);
- m_pszDescription=nullptr;
}
if(m_pszActionDescription!=nullptr)
{
SAFE_SYSFREESTRING(m_pszActionDescription);
- m_pszActionDescription=nullptr;
}
if(m_pIParent)
@@ -251,7 +247,7 @@ STDMETHODIMP CMAccessible::get_accParent(IDispatch **ppdispParent)
else if(m_hwnd)
{
HRESULT hr = AccessibleObjectFromWindow(m_hwnd, OBJID_WINDOW, IID_IAccessible, reinterpret_cast<void**>(ppdispParent));
- if( ! SUCCEEDED( hr ) || ! ppdispParent )
+ if (!SUCCEEDED(hr) || !*ppdispParent)
{
return S_FALSE;
}
@@ -670,9 +666,9 @@ STDMETHODIMP CMAccessible::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKe
VARIANT varParentRole;
VariantInit( &varParentRole );
- m_pIParent->get_accRole(varChild, &varParentRole);
-
- if( m_pIParent && varParentRole.lVal == ROLE_SYSTEM_COMBOBOX ) // edit in comboBox
+ if (m_pIParent
+ && SUCCEEDED(m_pIParent->get_accRole(varChild, &varParentRole))
+ && varParentRole.lVal == ROLE_SYSTEM_COMBOBOX) // edit in comboBox
{
m_pIParent->get_accKeyboardShortcut(varChild, pszKeyboardShortcut);
return S_OK;
@@ -1435,7 +1431,10 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags)
}
IMAccessible* pCurChild = nullptr;
- XAccessible* pChildXAcc = nullptr;
+ union {
+ XAccessible* pChildXAcc;
+ hyper nHyper = 0;
+ };
Reference<XAccessible> pRChildXAcc;
XAccessibleContext* pChildContext = nullptr;
int index = 0,delta=0;
@@ -1454,7 +1453,7 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags)
{
return nullptr;
}
- pCurChild->GetUNOInterface(reinterpret_cast<hyper*>(&pChildXAcc));
+ pCurChild->GetUNOInterface(&nHyper);
if(pChildXAcc==nullptr)
{
return nullptr;
@@ -1906,12 +1905,11 @@ STDMETHODIMP CMAccessible:: get_groupPosition(long __RPC_FAR *groupLevel,long __
if ( xGroupPosition.is() )
{
Sequence< sal_Int32 > rSeq = xGroupPosition->getGroupPosition( makeAny( pRContext ) );
- sal_Int32* pSeq = rSeq.getArray();
- if ( pSeq )
+ if (rSeq.getLength() >= 3)
{
- *groupLevel = pSeq[0];
- *similarItemsInGroup = pSeq[1];
- *positionInGroup = pSeq[2];
+ *groupLevel = rSeq[0];
+ *similarItemsInGroup = rSeq[1];
+ *positionInGroup = rSeq[2];
return S_OK;
}
return S_OK;
@@ -2088,13 +2086,11 @@ STDMETHODIMP CMAccessible:: get_windowHandle(HWND __RPC_FAR *windowHandle)
HWND nHwnd = m_hwnd;
IAccessible* pParent = m_pIParent;
- CMAccessible* pChild = this;
while((nHwnd==nullptr) && pParent)
{
- pChild = static_cast<CMAccessible*>(pParent);
- if(pChild)
+ if (CMAccessible* pChild = dynamic_cast<CMAccessible*>(pParent))
{
- pParent = static_cast<IAccessible*>(pChild->m_pIParent);
+ pParent = pChild->m_pIParent;
nHwnd = pChild->m_hwnd;
}
else
@@ -2313,8 +2309,11 @@ STDMETHODIMP CMAccessible::accSelect(long flagsSelect, VARIANT varChild)
if( flagsSelect&SELFLAG_TAKEFOCUS )
{
- XAccessible * pTempUNO = nullptr;
- pSelectAcc->GetUNOInterface(reinterpret_cast<hyper*>(&pTempUNO));
+ union {
+ XAccessible* pTempUNO;
+ hyper nHyper = 0;
+ };
+ pSelectAcc->GetUNOInterface(&nHyper);
if( pTempUNO == nullptr )
return NULL;
@@ -2641,12 +2640,13 @@ BOOL
CMAccessible::get_IAccessibleFromXAccessible(XAccessible * pXAcc, IAccessible **ppIA)
{
- ENTER_PROTECTED_BLOCK
+ try
+ {
// #CHECK#
if(ppIA == nullptr)
{
- return E_INVALIDARG;
+ return FALSE;
}
BOOL isGet = FALSE;
if(g_pAgent)
@@ -2657,7 +2657,11 @@ CMAccessible::get_IAccessibleFromXAccessible(XAccessible * pXAcc, IAccessible **
else
return FALSE;
- LEAVE_PROTECTED_BLOCK
+ }
+ catch(...)
+ {
+ return FALSE;
+ }
}
OUString CMAccessible::get_StringFromAny(Any const & pAny)
diff --git a/winaccessibility/source/UAccCOM/MAccessible.h b/winaccessibility/source/UAccCOM/MAccessible.h
index 87311e540f65..afd739a0bb6f 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.h
+++ b/winaccessibility/source/UAccCOM/MAccessible.h
@@ -165,12 +165,12 @@ public:
STDMETHOD(SetXAccessible)(hyper) override;
private:
- OLECHAR* m_pszName;
- OLECHAR* m_pszValue;
- OLECHAR* m_pszActionDescription;
+ BSTR m_pszName;
+ BSTR m_pszValue;
+ BSTR m_pszActionDescription;
unsigned short m_iRole;
DWORD m_dState;
- OLECHAR* m_pszDescription;
+ BSTR m_pszDescription;
IMAccessible* m_pIParent;
Location m_sLocation;