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

tdf#120703 (PVS): properly handle BSTR; fix enum comparison

V505 The 'alloca' function is used inside the loop. This can quickly overflow
     stack.
V745 A 'wchar_t *' type string is incorrectly converted to 'BSTR' type string.
     Consider using 'SysAllocString' function.
V768 The variable 'mnVersion' is of enum type. It is odd that it is used as a
     variable of a Boolean-type.

Change-Id: If7533483a53467b6901d1f39411a634d77bbd840
Reviewed-on: https://gerrit.libreoffice.org/62033Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
Tested-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 9d936de8
......@@ -354,18 +354,17 @@ STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG /*pErrorLog*/
return hr;
}
USES_CONVERSION;
for( unsigned long ind = 0; ind < aNum; ind++ )
{
// all information from the 'object' tag is in strings
if( aVal[ind].vt == VT_BSTR && !strcmp( OLE2T( aPropNames[ind].pstrName ), "src" ) )
if (aVal[ind].vt == VT_BSTR && !wcscmp(aPropNames[ind].pstrName, L"src"))
{
mCurFileUrl = wcsdup( aVal[ind].bstrVal );
}
else if( aVal[ind].vt == VT_BSTR
&& !strcmp( OLE2T( aPropNames[ind].pstrName ), "readonly" ) )
&& !wcscmp(aPropNames[ind].pstrName, L"readonly"))
{
if( !strcmp( OLE2T( aVal[ind].bstrVal ), "true" ) )
if (!wcscmp(aVal[ind].bstrVal, L"true"))
{
// the default value
mbViewOnly = TRUE;
......@@ -385,9 +384,16 @@ STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG /*pErrorLog*/
return hr;
mbReadyForActivation = FALSE;
hr = CBindStatusCallback<CSOActiveX>::Download( this, &CSOActiveX::CallbackCreateXInputStream, const_cast<OLECHAR *>(mCurFileUrl), m_spClientSite, FALSE );
if ( hr == MK_S_ASYNCHRONOUS )
hr = S_OK;
if (BSTR bStrUrl = SysAllocString(mCurFileUrl))
{
hr = CBindStatusCallback<CSOActiveX>::Download(
this, &CSOActiveX::CallbackCreateXInputStream, bStrUrl, m_spClientSite, FALSE);
SysFreeString(bStrUrl);
if (hr == MK_S_ASYNCHRONOUS)
hr = S_OK;
}
else
hr = E_OUTOFMEMORY;
if ( !SUCCEEDED( hr ) )
{
......@@ -912,23 +918,22 @@ SOVersion CSOActiveX::GetVersionConnected()
if( SUCCEEDED( hr ) && aOfficeVersion.vt == VT_BSTR )
{
USES_CONVERSION;
if( !strcmp( OLE2T( aOfficeName.bstrVal ), "StarOffice" ) )
if (!wcscmp(aOfficeName.bstrVal, L"StarOffice"))
{
if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "6.1", 3 ) )
if (!wcsncmp(aOfficeVersion.bstrVal, L"6.1", 3))
bResult = SO_61;
else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "6.0", 3 ) )
else if (!wcsncmp(aOfficeVersion.bstrVal, L"6.0", 3))
bResult = SO_60;
else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "5.2", 3 ) )
else if (!wcsncmp(aOfficeVersion.bstrVal, L"5.2", 3))
bResult = SO_52;
else
bResult = SO_UNKNOWN;
}
else // OpenOffice
{
if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "1.1", 3 ) )
if (!wcsncmp(aOfficeVersion.bstrVal, L"1.1", 3))
bResult = OO_11;
else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "1.0", 3 ) )
else if (!wcsncmp(aOfficeVersion.bstrVal, L"1.0", 3))
bResult = OO_10;
else
bResult = OO_UNKNOWN;
......@@ -1030,7 +1035,7 @@ HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di )
}
}
if( !mnVersion )
if (mnVersion == SO_NOT_DETECTED)
{
OutputError_Impl( mOffWin, CS_E_INVALID_VERSION );
return E_FAIL;
......
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