Kaydet (Commit) 9f8f804f authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#120703 (PVS)

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/62075
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst f93e29fe
...@@ -195,23 +195,19 @@ CMAccessible::~CMAccessible() ...@@ -195,23 +195,19 @@ CMAccessible::~CMAccessible()
if(m_pszName!=nullptr) if(m_pszName!=nullptr)
{ {
SAFE_SYSFREESTRING(m_pszName); SAFE_SYSFREESTRING(m_pszName);
m_pszName=nullptr;
} }
if(m_pszValue!=nullptr) if(m_pszValue!=nullptr)
{ {
SAFE_SYSFREESTRING(m_pszValue); SAFE_SYSFREESTRING(m_pszValue);
m_pszValue=nullptr;
} }
if(m_pszDescription!=nullptr) if(m_pszDescription!=nullptr)
{ {
SAFE_SYSFREESTRING(m_pszDescription); SAFE_SYSFREESTRING(m_pszDescription);
m_pszDescription=nullptr;
} }
if(m_pszActionDescription!=nullptr) if(m_pszActionDescription!=nullptr)
{ {
SAFE_SYSFREESTRING(m_pszActionDescription); SAFE_SYSFREESTRING(m_pszActionDescription);
m_pszActionDescription=nullptr;
} }
if(m_pIParent) if(m_pIParent)
...@@ -252,7 +248,7 @@ STDMETHODIMP CMAccessible::get_accParent(IDispatch **ppdispParent) ...@@ -252,7 +248,7 @@ STDMETHODIMP CMAccessible::get_accParent(IDispatch **ppdispParent)
else if(m_hwnd) else if(m_hwnd)
{ {
HRESULT hr = AccessibleObjectFromWindow(m_hwnd, OBJID_WINDOW, IID_IAccessible, reinterpret_cast<void**>(ppdispParent)); HRESULT hr = AccessibleObjectFromWindow(m_hwnd, OBJID_WINDOW, IID_IAccessible, reinterpret_cast<void**>(ppdispParent));
if( ! SUCCEEDED( hr ) || ! ppdispParent ) if (!SUCCEEDED(hr) || !*ppdispParent)
{ {
return S_FALSE; return S_FALSE;
} }
...@@ -671,9 +667,9 @@ STDMETHODIMP CMAccessible::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKe ...@@ -671,9 +667,9 @@ STDMETHODIMP CMAccessible::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKe
VARIANT varParentRole; VARIANT varParentRole;
VariantInit( &varParentRole ); VariantInit( &varParentRole );
m_pIParent->get_accRole(varChild, &varParentRole); if (m_pIParent
&& SUCCEEDED(m_pIParent->get_accRole(varChild, &varParentRole))
if( m_pIParent && varParentRole.lVal == ROLE_SYSTEM_COMBOBOX ) // edit in comboBox && varParentRole.lVal == ROLE_SYSTEM_COMBOBOX) // edit in comboBox
{ {
m_pIParent->get_accKeyboardShortcut(varChild, pszKeyboardShortcut); m_pIParent->get_accKeyboardShortcut(varChild, pszKeyboardShortcut);
return S_OK; return S_OK;
...@@ -1436,7 +1432,10 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) ...@@ -1436,7 +1432,10 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags)
} }
IMAccessible* pCurChild = nullptr; IMAccessible* pCurChild = nullptr;
XAccessible* pChildXAcc = nullptr; union {
XAccessible* pChildXAcc;
hyper nHyper = 0;
};
Reference<XAccessible> pRChildXAcc; Reference<XAccessible> pRChildXAcc;
XAccessibleContext* pChildContext = nullptr; XAccessibleContext* pChildContext = nullptr;
int index = 0,delta=0; int index = 0,delta=0;
...@@ -1455,7 +1454,7 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) ...@@ -1455,7 +1454,7 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags)
{ {
return nullptr; return nullptr;
} }
pCurChild->GetUNOInterface(reinterpret_cast<hyper*>(&pChildXAcc)); pCurChild->GetUNOInterface(&nHyper);
if(pChildXAcc==nullptr) if(pChildXAcc==nullptr)
{ {
return nullptr; return nullptr;
...@@ -1907,12 +1906,11 @@ STDMETHODIMP CMAccessible:: get_groupPosition(long __RPC_FAR *groupLevel,long __ ...@@ -1907,12 +1906,11 @@ STDMETHODIMP CMAccessible:: get_groupPosition(long __RPC_FAR *groupLevel,long __
if ( xGroupPosition.is() ) if ( xGroupPosition.is() )
{ {
Sequence< sal_Int32 > rSeq = xGroupPosition->getGroupPosition( makeAny( pRContext ) ); Sequence< sal_Int32 > rSeq = xGroupPosition->getGroupPosition( makeAny( pRContext ) );
sal_Int32* pSeq = rSeq.getArray(); if (rSeq.getLength() >= 3)
if ( pSeq )
{ {
*groupLevel = pSeq[0]; *groupLevel = rSeq[0];
*similarItemsInGroup = pSeq[1]; *similarItemsInGroup = rSeq[1];
*positionInGroup = pSeq[2]; *positionInGroup = rSeq[2];
return S_OK; return S_OK;
} }
return S_OK; return S_OK;
...@@ -2089,13 +2087,11 @@ STDMETHODIMP CMAccessible:: get_windowHandle(HWND __RPC_FAR *windowHandle) ...@@ -2089,13 +2087,11 @@ STDMETHODIMP CMAccessible:: get_windowHandle(HWND __RPC_FAR *windowHandle)
HWND nHwnd = m_hwnd; HWND nHwnd = m_hwnd;
IAccessible* pParent = m_pIParent; IAccessible* pParent = m_pIParent;
CMAccessible* pChild = this;
while((nHwnd==nullptr) && pParent) while((nHwnd==nullptr) && pParent)
{ {
pChild = static_cast<CMAccessible*>(pParent); if (CMAccessible* pChild = dynamic_cast<CMAccessible*>(pParent))
if(pChild)
{ {
pParent = static_cast<IAccessible*>(pChild->m_pIParent); pParent = pChild->m_pIParent;
nHwnd = pChild->m_hwnd; nHwnd = pChild->m_hwnd;
} }
else else
...@@ -2314,8 +2310,11 @@ STDMETHODIMP CMAccessible::accSelect(long flagsSelect, VARIANT varChild) ...@@ -2314,8 +2310,11 @@ STDMETHODIMP CMAccessible::accSelect(long flagsSelect, VARIANT varChild)
if( flagsSelect&SELFLAG_TAKEFOCUS ) if( flagsSelect&SELFLAG_TAKEFOCUS )
{ {
XAccessible * pTempUNO = nullptr; union {
pSelectAcc->GetUNOInterface(reinterpret_cast<hyper*>(&pTempUNO)); XAccessible* pTempUNO;
hyper nHyper = 0;
};
pSelectAcc->GetUNOInterface(&nHyper);
if( pTempUNO == nullptr ) if( pTempUNO == nullptr )
return NULL; return NULL;
...@@ -2642,12 +2641,13 @@ BOOL ...@@ -2642,12 +2641,13 @@ BOOL
CMAccessible::get_IAccessibleFromXAccessible(XAccessible * pXAcc, IAccessible **ppIA) CMAccessible::get_IAccessibleFromXAccessible(XAccessible * pXAcc, IAccessible **ppIA)
{ {
ENTER_PROTECTED_BLOCK try
{
// #CHECK# // #CHECK#
if(ppIA == nullptr) if(ppIA == nullptr)
{ {
return E_INVALIDARG; return FALSE;
} }
BOOL isGet = FALSE; BOOL isGet = FALSE;
if(g_pAgent) if(g_pAgent)
...@@ -2658,7 +2658,11 @@ CMAccessible::get_IAccessibleFromXAccessible(XAccessible * pXAcc, IAccessible ** ...@@ -2658,7 +2658,11 @@ CMAccessible::get_IAccessibleFromXAccessible(XAccessible * pXAcc, IAccessible **
else else
return FALSE; return FALSE;
LEAVE_PROTECTED_BLOCK }
catch(...)
{
return FALSE;
}
} }
OUString CMAccessible::get_StringFromAny(Any const & pAny) OUString CMAccessible::get_StringFromAny(Any const & pAny)
......
...@@ -165,12 +165,12 @@ public: ...@@ -165,12 +165,12 @@ public:
STDMETHOD(SetXAccessible)(hyper) override; STDMETHOD(SetXAccessible)(hyper) override;
private: private:
OLECHAR* m_pszName; BSTR m_pszName;
OLECHAR* m_pszValue; BSTR m_pszValue;
OLECHAR* m_pszActionDescription; BSTR m_pszActionDescription;
unsigned short m_iRole; unsigned short m_iRole;
DWORD m_dState; DWORD m_dState;
OLECHAR* m_pszDescription; BSTR m_pszDescription;
IMAccessible* m_pIParent; IMAccessible* m_pIParent;
Location m_sLocation; Location m_sLocation;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment