tdf#120703 PVS: Silence V575 warnings
V575 The potential null pointer is passed into 'foo' function Add asserts to those cases that are related to OOM cases. There's nothing to be done if the assertions fail anyway. Change-Id: I92ac95d44f512aa1948b1552b0e1f6da695a9f92 Reviewed-on: https://gerrit.libreoffice.org/70008 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
@@ -2239,6 +2239,7 @@ static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart)
|
||||
OString aString = OUStringToOString(aPartInfo, RTL_TEXTENCODING_UTF8);
|
||||
|
||||
char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
||||
assert(pMemory); // Don't handle OOM conditions
|
||||
strcpy(pMemory, aString.getStr());
|
||||
return pMemory;
|
||||
}
|
||||
@@ -2259,6 +2260,7 @@ static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis)
|
||||
OUString sRectangles = pDoc->getPartPageRectangles();
|
||||
OString aString = OUStringToOString(sRectangles, RTL_TEXTENCODING_UTF8);
|
||||
char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
||||
assert(pMemory); // Don't handle OOM conditions
|
||||
strcpy(pMemory, aString.getStr());
|
||||
return pMemory;
|
||||
|
||||
@@ -2280,6 +2282,7 @@ static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
|
||||
OUString sName = pDoc->getPartName( nPart );
|
||||
OString aString = OUStringToOString(sName, RTL_TEXTENCODING_UTF8);
|
||||
char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
||||
assert(pMemory); // Don't handle OOM conditions
|
||||
strcpy(pMemory, aString.getStr());
|
||||
return pMemory;
|
||||
|
||||
@@ -2301,6 +2304,7 @@ static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart)
|
||||
OUString sHash = pDoc->getPartHash(nPart);
|
||||
OString aString = OUStringToOString(sHash, RTL_TEXTENCODING_UTF8);
|
||||
char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
||||
assert(pMemory); // Don't handle OOM conditions
|
||||
strcpy(pMemory, aString.getStr());
|
||||
return pMemory;
|
||||
|
||||
@@ -3100,6 +3104,7 @@ static char* doc_getTextSelection(LibreOfficeKitDocument* pThis, const char* pMi
|
||||
aRet = pDoc->getTextSelection("text/plain;charset=utf-8", aUsedMimeType);
|
||||
|
||||
char* pMemory = static_cast<char*>(malloc(aRet.getLength() + 1));
|
||||
assert(pMemory); // Don't handle OOM conditions
|
||||
strcpy(pMemory, aRet.getStr());
|
||||
|
||||
if (pUsedMimeType)
|
||||
@@ -3215,6 +3220,7 @@ static char* getLanguages(const char* pCommand)
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
char* pJson = static_cast<char*>(malloc(aStream.str().size() + 1));
|
||||
assert(pJson); // Don't handle OOM conditions
|
||||
strcpy(pJson, aStream.str().c_str());
|
||||
pJson[aStream.str().size()] = '\0';
|
||||
return pJson;
|
||||
@@ -3253,6 +3259,7 @@ static char* getFonts (const char* pCommand)
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
char* pJson = static_cast<char*>(malloc(aStream.str().size() + 1));
|
||||
assert(pJson); // Don't handle OOM conditions
|
||||
strcpy(pJson, aStream.str().c_str());
|
||||
pJson[aStream.str().size()] = '\0';
|
||||
return pJson;
|
||||
@@ -3305,6 +3312,7 @@ static char* getFontSubset (const OString& aFontName)
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
char* pJson = static_cast<char*>(malloc(aStream.str().size() + 1));
|
||||
assert(pJson); // Don't handle OOM conditions
|
||||
strcpy(pJson, aStream.str().c_str());
|
||||
pJson[aStream.str().size()] = '\0';
|
||||
return pJson;
|
||||
@@ -3429,6 +3437,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
char* pJson = static_cast<char*>(malloc(aStream.str().size() + 1));
|
||||
assert(pJson); // Don't handle OOM conditions
|
||||
strcpy(pJson, aStream.str().c_str());
|
||||
pJson[aStream.str().size()] = '\0';
|
||||
return pJson;
|
||||
@@ -3650,6 +3659,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
|
||||
OString aString = OUStringToOString(aHeaders, RTL_TEXTENCODING_UTF8);
|
||||
|
||||
char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
||||
assert(pMemory); // Don't handle OOM conditions
|
||||
strcpy(pMemory, aString.getStr());
|
||||
return pMemory;
|
||||
}
|
||||
@@ -3701,6 +3711,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
|
||||
OString aString = pDoc->getCellCursor(nOutputWidth, nOutputHeight, nTileWidth, nTileHeight);
|
||||
|
||||
char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
||||
assert(pMemory); // Don't handle OOM conditions
|
||||
strcpy(pMemory, aString.getStr());
|
||||
return pMemory;
|
||||
}
|
||||
@@ -4194,6 +4205,7 @@ static char* lo_getError (LibreOfficeKit *pThis)
|
||||
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
|
||||
OString aString = OUStringToOString(pLib->maLastExceptionMsg, RTL_TEXTENCODING_UTF8);
|
||||
char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
|
||||
assert(pMemory); // Don't handle OOM conditions
|
||||
strcpy(pMemory, aString.getStr());
|
||||
return pMemory;
|
||||
}
|
||||
@@ -4290,6 +4302,7 @@ static char* lo_getVersionInfo(SAL_UNUSED_PARAMETER LibreOfficeKit* /*pThis*/)
|
||||
const OString sVersionStr = OUStringToOString(ReplaceStringHookProc(sVersionStrTemplate), RTL_TEXTENCODING_UTF8);
|
||||
|
||||
char* pVersion = static_cast<char*>(malloc(sVersionStr.getLength() + 1));
|
||||
assert(pVersion); // Don't handle OOM conditions
|
||||
strcpy(pVersion, sVersionStr.getStr());
|
||||
return pVersion;
|
||||
}
|
||||
|
@@ -528,7 +528,7 @@ static void do_msvcr_magic(OUString const &jvm_dll)
|
||||
}
|
||||
|
||||
PIMAGE_DOS_HEADER dos_hdr = static_cast<PIMAGE_DOS_HEADER>(malloc(st.st_size));
|
||||
|
||||
assert(dos_hdr);
|
||||
if (fread(dos_hdr, st.st_size, 1, f) != 1 ||
|
||||
memcmp(dos_hdr, "MZ", 2) != 0 ||
|
||||
dos_hdr->e_lfanew < 0 ||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -208,6 +209,7 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
if ( value != NULL )
|
||||
size += wcslen( PATHSEPARATOR ) + wcslen( value );
|
||||
wchar_t* envstr = (wchar_t*) malloc( size*sizeof(wchar_t) );
|
||||
assert(envstr);
|
||||
wcscpy( envstr, ENVVARNAME );
|
||||
wcscat( envstr, L"=" );
|
||||
wcscat( envstr, path );
|
||||
@@ -312,6 +314,7 @@ wchar_t* createCommandLine( wchar_t const * appendix )
|
||||
/* create the command line */
|
||||
cmdline = (wchar_t*) malloc( (wcslen( DQUOTE ) + wcslen( cmdname ) +
|
||||
wcslen ( DQUOTE ) + wcslen( SPACE ) + wcslen( appendix ) + 1) * sizeof(wchar_t) );
|
||||
assert(cmdline);
|
||||
wcscpy( cmdline, DQUOTE );
|
||||
wcscat( cmdline, cmdname );
|
||||
wcscat( cmdline, DQUOTE );
|
||||
|
@@ -345,11 +345,12 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
|
||||
}
|
||||
|
||||
WCHAR* szFileMask = static_cast< WCHAR* >( malloc( sizeof( WCHAR ) * ( nLen + nSuffLen + 1 ) ) );
|
||||
|
||||
assert(szFileMask); // Don't handle OOM conditions
|
||||
wcscpy( szFileMask, o3tl::toW(rtl_uString_getStr( pPath )) );
|
||||
wcscat( szFileMask, pSuffix );
|
||||
|
||||
pDirectory = static_cast<LPDIRECTORY>(HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY)));
|
||||
assert(pDirectory); // Don't handle OOM conditions
|
||||
pDirectory->hFind = FindFirstFileW(szFileMask, &pDirectory->aFirstData);
|
||||
|
||||
if (!IsValidHandle(pDirectory->hFind))
|
||||
@@ -437,6 +438,7 @@ static oslFileError osl_openLocalRoot(
|
||||
Directory_Impl *pDirImpl;
|
||||
|
||||
pDirImpl = static_cast<Directory_Impl*>(malloc( sizeof(Directory_Impl)));
|
||||
assert(pDirImpl); // Don't handle OOM conditions
|
||||
ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
|
||||
rtl_uString_newFromString( &pDirImpl->m_pDirectoryPath, strSysPath );
|
||||
|
||||
@@ -501,6 +503,7 @@ static oslFileError osl_openFileDirectory(
|
||||
*pDirectory = nullptr;
|
||||
|
||||
Directory_Impl *pDirImpl = static_cast<Directory_Impl*>(malloc(sizeof(Directory_Impl)));
|
||||
assert(pDirImpl); // Don't handle OOM conditions
|
||||
ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
|
||||
rtl_uString_newFromString( &pDirImpl->m_pDirectoryPath, strDirectoryPath );
|
||||
|
||||
@@ -566,6 +569,7 @@ static oslFileError osl_openNetworkServer(
|
||||
Directory_Impl *pDirImpl;
|
||||
|
||||
pDirImpl = static_cast<Directory_Impl*>(malloc(sizeof(Directory_Impl)));
|
||||
assert(pDirImpl); // Don't handle OOM conditions
|
||||
ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
|
||||
pDirImpl->uType = DIRECTORYTYPE_NETROOT;
|
||||
pDirImpl->hDirectory = hEnum;
|
||||
@@ -1068,18 +1072,24 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
|
||||
{
|
||||
DirectoryItem_Impl *pItemImpl =
|
||||
static_cast<DirectoryItem_Impl*>(malloc(sizeof(DirectoryItem_Impl)));
|
||||
if (!pItemImpl)
|
||||
error = osl_File_E_NOMEM;
|
||||
|
||||
ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
|
||||
osl_acquireDirectoryItem( static_cast<oslDirectoryItem>(pItemImpl) );
|
||||
if (osl_File_E_None == error)
|
||||
{
|
||||
ZeroMemory(pItemImpl, sizeof(DirectoryItem_Impl));
|
||||
osl_acquireDirectoryItem(static_cast<oslDirectoryItem>(pItemImpl));
|
||||
|
||||
CopyMemory( &pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATAW) );
|
||||
rtl_uString_newFromString( &pItemImpl->m_pFullPath, strSysFilePath );
|
||||
CopyMemory(&pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATAW));
|
||||
rtl_uString_newFromString(&pItemImpl->m_pFullPath, strSysFilePath);
|
||||
|
||||
// MT: This costs 600ms startup time on fast v60x!
|
||||
// GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
|
||||
// MT: This costs 600ms startup time on fast v60x!
|
||||
// GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
|
||||
|
||||
pItemImpl->uType = DIRECTORYITEM_FILE;
|
||||
*pItem = pItemImpl;
|
||||
}
|
||||
|
||||
pItemImpl->uType = DIRECTORYITEM_FILE;
|
||||
*pItem = pItemImpl;
|
||||
FindClose( hFind );
|
||||
}
|
||||
else
|
||||
|
@@ -603,7 +603,7 @@ static void osl_encodeURL_( rtl_uString *strURL, rtl_String **pstrEncodedURL )
|
||||
rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
|
||||
|
||||
pszEncodedURL = static_cast<sal_Char*>(malloc( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) ));
|
||||
|
||||
assert(pszEncodedURL); // Don't handle OOM conditions
|
||||
pURLDest = pszEncodedURL;
|
||||
pURLScan = rtl_string_getStr( strUTF8 );
|
||||
nURLScanLen = rtl_string_getLength( strUTF8 );
|
||||
|
@@ -136,12 +136,14 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options
|
||||
PSECURITY_DESCRIPTOR pSecDesc;
|
||||
|
||||
pSecDesc = static_cast< PSECURITY_DESCRIPTOR >(malloc(SECURITY_DESCRIPTOR_MIN_LENGTH));
|
||||
assert(pSecDesc); // Don't handle OOM conditions
|
||||
|
||||
/* add a NULL disc. ACL to the security descriptor */
|
||||
OSL_VERIFY(InitializeSecurityDescriptor(pSecDesc, SECURITY_DESCRIPTOR_REVISION));
|
||||
OSL_VERIFY(SetSecurityDescriptorDacl(pSecDesc, TRUE, nullptr, FALSE));
|
||||
|
||||
pSecAttr = static_cast< PSECURITY_ATTRIBUTES >(malloc(sizeof(SECURITY_ATTRIBUTES)));
|
||||
assert(pSecAttr); // Don't handle OOM conditions
|
||||
pSecAttr->nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
pSecAttr->lpSecurityDescriptor = pSecDesc;
|
||||
pSecAttr->bInheritHandle = TRUE;
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <osl/security.h>
|
||||
#include <osl/diagnose.h>
|
||||
#include <osl/thread.h>
|
||||
@@ -782,6 +783,7 @@ static bool getUserNameImpl(oslSecurity Security, rtl_uString **strName, bool b
|
||||
|
||||
WNetGetUserW(nullptr, nullptr, &needed);
|
||||
pNameW = static_cast<sal_Unicode *>(malloc (needed*sizeof(sal_Unicode)));
|
||||
assert(pNameW); // Don't handle OOM conditions
|
||||
|
||||
if (WNetGetUserW(nullptr, o3tl::toW(pNameW), &needed) == NO_ERROR)
|
||||
{
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <windows.h>
|
||||
#include <msiquery.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
@@ -66,6 +67,7 @@ static void RegisterActiveXNative( const wchar_t* pActiveXPath, int nMode, BOOL
|
||||
if ( nLen > nRemoveLen )
|
||||
{
|
||||
wchar_t* pProgramPath = static_cast<wchar_t*>( malloc( (nLen - nRemoveLen + 1) * sizeof(wchar_t) ) );
|
||||
assert(pProgramPath); // Don't handle OOM conditions
|
||||
wcsncpy( pProgramPath, pActiveXPath, nLen - nRemoveLen );
|
||||
pProgramPath[ nLen - nRemoveLen ] = 0;
|
||||
|
||||
@@ -102,6 +104,7 @@ static BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppV
|
||||
sz++;
|
||||
DWORD nbytes = sz * sizeof( wchar_t );
|
||||
wchar_t* buff = static_cast<wchar_t*>( malloc( nbytes ) );
|
||||
assert(buff); // Don't handle OOM conditions
|
||||
ZeroMemory( buff, nbytes );
|
||||
MsiGetPropertyW( hMSI, pPropName, buff, &sz );
|
||||
*ppValue = buff;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <msiquery.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -44,6 +45,7 @@ static BOOL GetMsiPropA( MSIHANDLE hMSI, const char* pPropName, char** ppValue )
|
||||
sz++;
|
||||
DWORD nbytes = sz * sizeof( char );
|
||||
char* buff = static_cast<char*>( malloc( nbytes ) );
|
||||
assert(buff); // Don't handle OOM conditions
|
||||
ZeroMemory( buff, nbytes );
|
||||
MsiGetPropertyA( hMSI, pPropName, buff, &sz );
|
||||
*ppValue = buff;
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <windows.h>
|
||||
#include <msiquery.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
@@ -37,6 +38,7 @@ static BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppV
|
||||
sz++;
|
||||
DWORD nbytes = sz * sizeof( wchar_t );
|
||||
wchar_t* buff = static_cast<wchar_t*>( malloc( nbytes ) );
|
||||
assert(buff); // Don't handle OOM conditions
|
||||
ZeroMemory( buff, nbytes );
|
||||
MsiGetPropertyW( hMSI, pPropName, buff, &sz );
|
||||
*ppValue = buff;
|
||||
|
@@ -56,6 +56,7 @@ typedef _W64 int ssize_t;
|
||||
#endif
|
||||
|
||||
#include "def.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#ifdef hpux
|
||||
#define sigvec sigvector
|
||||
@@ -522,7 +523,7 @@ void freefile(struct filepointer *fp)
|
||||
char *copy(char const *str)
|
||||
{
|
||||
char *p = (char *)malloc(strlen(str) + 1);
|
||||
|
||||
assert(p); // Don't handle OOM conditions
|
||||
strcpy(p, str);
|
||||
return p;
|
||||
}
|
||||
@@ -718,6 +719,7 @@ char* append_slash(char *path)
|
||||
new_string = path;
|
||||
} else {
|
||||
new_string = (char*)malloc(sizeof(char) * (strlen(path) + 2));
|
||||
assert(new_string); // Don't handle OOM conditions
|
||||
strcpy(new_string, path);
|
||||
if (native_win_slashes)
|
||||
strcat(new_string, "\\");
|
||||
|
@@ -635,14 +635,15 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
|
||||
return 0;
|
||||
|
||||
np = myPoints.size();
|
||||
|
||||
pa = static_cast<ControlPoint*>(calloc(np, sizeof(ControlPoint)));
|
||||
assert(pa != nullptr);
|
||||
|
||||
if (np > 0)
|
||||
memcpy( pa, &myPoints[0], np*sizeof(ControlPoint) );
|
||||
{
|
||||
pa = static_cast<ControlPoint*>(calloc(np, sizeof(ControlPoint)));
|
||||
assert(pa != nullptr);
|
||||
|
||||
*pointArray = pa;
|
||||
memcpy(pa, &myPoints[0], np * sizeof(ControlPoint));
|
||||
|
||||
*pointArray = pa;
|
||||
}
|
||||
return np;
|
||||
}
|
||||
|
||||
@@ -2537,6 +2538,7 @@ int GetTTNameRecords(TrueTypeFont const *ttf, NameRecord **nr)
|
||||
}
|
||||
|
||||
NameRecord* rec = static_cast<NameRecord*>(calloc(n, sizeof(NameRecord)));
|
||||
assert(rec);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
int nLargestFixedOffsetPos = 6 + 10 + 12 * i;
|
||||
|
@@ -1324,6 +1324,7 @@ static DEVMODEW const * ImplSalSetCopies( DEVMODEW const * pDevMode, sal_uLong n
|
||||
nCopies = 32765;
|
||||
sal_uLong nDevSize = pDevMode->dmSize+pDevMode->dmDriverExtra;
|
||||
LPDEVMODEW pNewDevMode = static_cast<LPDEVMODEW>(std::malloc( nDevSize ));
|
||||
assert(pNewDevMode); // Don't handle OOM conditions
|
||||
memcpy( pNewDevMode, pDevMode, nDevSize );
|
||||
pNewDevMode->dmFields |= DM_COPIES;
|
||||
pNewDevMode->dmCopies = static_cast<short>(static_cast<sal_uInt16>(nCopies));
|
||||
|
Reference in New Issue
Block a user