WaE: C6011 Dereferencing NULL pointer warnings from unchecked malloc
upgrade OSL_ASSERT to assert and add a few more Change-Id: Ib52ca573d9e0878fef94dec40410f71bc94dea04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166914 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
parent
51407b6f8d
commit
d25b88ca2b
@ -87,7 +87,7 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
|
||||
WCHAR langCode[ELP_LANGUAGE_FIELD_LENGTH];
|
||||
WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
|
||||
|
||||
OSL_ASSERT( ppLocale );
|
||||
assert(ppLocale);
|
||||
|
||||
/* get the locale name to retrieve information from */
|
||||
/* and call GetLocaleInfo to retrieve the iso codes */
|
||||
|
@ -149,6 +149,7 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident)
|
||||
if (hProcess)
|
||||
{
|
||||
pProcImpl = static_cast< oslProcessImpl*>( malloc(sizeof(oslProcessImpl)) );
|
||||
assert(pProcImpl && "Don't handle OOM conditions");
|
||||
pProcImpl->m_hProcess = hProcess;
|
||||
pProcImpl->m_IdProcess = Ident;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ namespace /* private */
|
||||
sal_uInt32 env_vars_count,
|
||||
/*in|out*/ std::vector<OUString>* merged_env)
|
||||
{
|
||||
OSL_ASSERT(env_vars && env_vars_count > 0 && merged_env);
|
||||
assert(env_vars && env_vars_count > 0 && merged_env);
|
||||
|
||||
read_environment(merged_env);
|
||||
|
||||
|
@ -371,7 +371,7 @@ DWORD GetPrivateProfileStringWrapper(const osl_TProfileImpl* pProfile,
|
||||
char* pszString, sal_uInt32 MaxLen,
|
||||
const char* pszDefault)
|
||||
{
|
||||
OSL_ASSERT(pProfile && (!MaxLen || pszString));
|
||||
assert(pProfile && (!MaxLen || pszString));
|
||||
|
||||
rtl_uString *pSection = nullptr, *pEntry = nullptr, *pDefault = nullptr;
|
||||
if (pszSection)
|
||||
@ -412,10 +412,10 @@ bool WritePrivateProfileStringWrapper(const osl_TProfileImpl* pProfile,
|
||||
const char* pszSection, const char* pszEntry,
|
||||
const char* pszString)
|
||||
{
|
||||
OSL_ASSERT(pProfile && pszSection);
|
||||
assert(pProfile && pszSection);
|
||||
rtl_uString *pSection, *pEntry = nullptr, *pString = nullptr;
|
||||
rtl_string2UString(&pSection, pszSection, strlen(pszSection), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS);
|
||||
OSL_ASSERT(pSection);
|
||||
assert(pSection);
|
||||
if (pszEntry)
|
||||
{
|
||||
rtl_string2UString(&pEntry, pszEntry, strlen(pszEntry), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS);
|
||||
@ -1258,6 +1258,7 @@ static bool putLine(osl_TFile* pFile, const char *pszLine)
|
||||
if ( pFile->m_pWriteBuf == nullptr )
|
||||
{
|
||||
pFile->m_pWriteBuf = static_cast<char*>(malloc(Len+3));
|
||||
assert(pFile->m_pWriteBuf && "Don't handle OOM conditions");
|
||||
pFile->m_nWriteBufLen = Len+3;
|
||||
pFile->m_nWriteBufFree = Len+3;
|
||||
}
|
||||
|
@ -329,13 +329,13 @@ oslSocketAddr SAL_CALL osl_copySocketAddr(oslSocketAddr Addr)
|
||||
|
||||
sal_Bool SAL_CALL osl_isEqualSocketAddr(oslSocketAddr Addr1, oslSocketAddr Addr2)
|
||||
{
|
||||
OSL_ASSERT(Addr1);
|
||||
OSL_ASSERT(Addr2);
|
||||
assert(Addr1);
|
||||
assert(Addr2);
|
||||
struct sockaddr* pAddr1= &(Addr1->m_sockaddr);
|
||||
struct sockaddr* pAddr2= &(Addr2->m_sockaddr);
|
||||
|
||||
OSL_ASSERT(pAddr1);
|
||||
OSL_ASSERT(pAddr2);
|
||||
assert(pAddr1);
|
||||
assert(pAddr2);
|
||||
|
||||
if (pAddr1->sa_family == pAddr2->sa_family)
|
||||
{
|
||||
@ -868,7 +868,7 @@ oslSocketAddr SAL_CALL osl_getPeerAddrOfSocket(oslSocket pSocket)
|
||||
|
||||
sal_Bool SAL_CALL osl_bindAddrToSocket ( oslSocket pSocket, oslSocketAddr pAddr)
|
||||
{
|
||||
OSL_ASSERT( pAddr );
|
||||
assert(pAddr);
|
||||
|
||||
if (pSocket == nullptr) /* ENOTSOCK */
|
||||
return false;
|
||||
|
@ -152,7 +152,7 @@ void SAL_CALL osl_resumeThread(oslThread Thread)
|
||||
{
|
||||
osl_TThreadImpl* pThreadImpl= static_cast<osl_TThreadImpl*>(Thread);
|
||||
|
||||
OSL_ASSERT(pThreadImpl); /* valid ptr? */
|
||||
assert(pThreadImpl); /* valid ptr? */
|
||||
|
||||
ResumeThread(pThreadImpl->m_hThread);
|
||||
}
|
||||
@ -161,7 +161,7 @@ void SAL_CALL osl_suspendThread(oslThread Thread)
|
||||
{
|
||||
osl_TThreadImpl* pThreadImpl= static_cast<osl_TThreadImpl*>(Thread);
|
||||
|
||||
OSL_ASSERT(pThreadImpl); /* valid ptr? */
|
||||
assert(pThreadImpl); /* valid ptr? */
|
||||
|
||||
SuspendThread(pThreadImpl->m_hThread);
|
||||
}
|
||||
@ -172,7 +172,7 @@ void SAL_CALL osl_setThreadPriority(oslThread Thread,
|
||||
int winPriority;
|
||||
osl_TThreadImpl* pThreadImpl= static_cast<osl_TThreadImpl*>(Thread);
|
||||
|
||||
OSL_ASSERT(pThreadImpl); /* valid ptr? */
|
||||
assert(pThreadImpl); /* valid ptr? */
|
||||
|
||||
/* map enum to WIN32 levels
|
||||
it would be faster and more elegant to preset
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <sal/config.h>
|
||||
#include "assert.h"
|
||||
#include "system.h"
|
||||
|
||||
#include "filetime.hxx"
|
||||
@ -33,7 +34,7 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal)
|
||||
|
||||
typedef VOID (WINAPI *GetSystemTimePreciseAsFileTime_PROC)(LPFILETIME);
|
||||
|
||||
OSL_ASSERT(pTimeVal != nullptr);
|
||||
assert(pTimeVal != nullptr);
|
||||
|
||||
static GetSystemTimePreciseAsFileTime_PROC pGetSystemTimePreciseAsFileTime = []()
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ bool isPathnameUrl(std::u16string_view url)
|
||||
|
||||
bool resolvePathnameUrl(OUString * url)
|
||||
{
|
||||
OSL_ASSERT(url);
|
||||
assert(url);
|
||||
if (!isPathnameUrl(*url) ||
|
||||
(osl::FileBase::getFileURLFromSystemPath(
|
||||
url->copy(VND_SUN_STAR_PATHNAME.size()), *url) ==
|
||||
@ -835,7 +835,7 @@ void SAL_CALL rtl_bootstrap_expandMacros(rtl_uString ** macro)
|
||||
|
||||
void rtl_bootstrap_encode(rtl_uString const * value, rtl_uString ** encoded)
|
||||
{
|
||||
OSL_ASSERT(value);
|
||||
assert(value);
|
||||
OUStringBuffer b(value->length+5);
|
||||
for (sal_Int32 i = 0; i < value->length; ++i)
|
||||
{
|
||||
@ -861,7 +861,7 @@ int hex(sal_Unicode c)
|
||||
|
||||
sal_Unicode read(std::u16string_view text, std::size_t * pos, bool * escaped)
|
||||
{
|
||||
OSL_ASSERT(pos && *pos < text.length() && escaped);
|
||||
assert(pos && *pos < text.length() && escaped);
|
||||
sal_Unicode c = text[(*pos)++];
|
||||
if (c == '\\')
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ void SAL_CALL rtl_byte_sequence_reference2One(
|
||||
{
|
||||
sal_Sequence * pSequence;
|
||||
|
||||
OSL_ENSURE( ppSequence, "### null ptr!" );
|
||||
assert(ppSequence && "### null ptr!");
|
||||
pSequence = *ppSequence;
|
||||
|
||||
if (pSequence->nRefCount > 1)
|
||||
@ -132,7 +132,7 @@ void SAL_CALL rtl_byte_sequence_realloc(
|
||||
void SAL_CALL rtl_byte_sequence_acquire( sal_Sequence *pSequence )
|
||||
SAL_THROW_EXTERN_C()
|
||||
{
|
||||
OSL_ASSERT( pSequence );
|
||||
assert(pSequence);
|
||||
osl_atomic_increment( &(pSequence->nRefCount) );
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ void SAL_CALL rtl_byte_sequence_release( sal_Sequence *pSequence )
|
||||
void SAL_CALL rtl_byte_sequence_construct( sal_Sequence **ppSequence , sal_Int32 nLength )
|
||||
SAL_THROW_EXTERN_C()
|
||||
{
|
||||
OSL_ASSERT( ppSequence );
|
||||
assert(ppSequence);
|
||||
if( *ppSequence )
|
||||
{
|
||||
rtl_byte_sequence_release( *ppSequence );
|
||||
@ -178,7 +178,7 @@ void SAL_CALL rtl_byte_sequence_construct( sal_Sequence **ppSequence , sal_Int32
|
||||
void SAL_CALL rtl_byte_sequence_constructNoDefault( sal_Sequence **ppSequence , sal_Int32 nLength )
|
||||
SAL_THROW_EXTERN_C()
|
||||
{
|
||||
OSL_ASSERT( ppSequence );
|
||||
assert(ppSequence);
|
||||
if( *ppSequence )
|
||||
{
|
||||
rtl_byte_sequence_release( *ppSequence );
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hash.hxx"
|
||||
@ -76,10 +77,12 @@ static sal_uInt32 hashString(rtl_uString *pString)
|
||||
static StringHashTable * rtl_str_hash_new(sal_uInt32 nSize)
|
||||
{
|
||||
StringHashTable *pHash = static_cast<StringHashTable *>(malloc(sizeof(StringHashTable)));
|
||||
assert(pHash && "Don't handle OOM conditions");
|
||||
|
||||
pHash->nEntries = 0;
|
||||
pHash->nSize = getNextSize (nSize);
|
||||
pHash->pData = static_cast< rtl_uString ** >(calloc(pHash->nSize, sizeof(rtl_uString *)));
|
||||
assert(pHash->pData && "Don't handle OOM conditions");
|
||||
|
||||
return pHash;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ static bool rtl_impl_convertUStringToString(rtl_String ** pTarget,
|
||||
if ( *pTarget )
|
||||
rtl_string_release( *pTarget );
|
||||
*pTarget = rtl_string_ImplAlloc( nLength );
|
||||
OSL_ASSERT(*pTarget != nullptr);
|
||||
assert(*pTarget != nullptr);
|
||||
pBuffer = (*pTarget)->buffer;
|
||||
do
|
||||
{
|
||||
@ -200,7 +200,7 @@ static bool rtl_impl_convertUStringToString(rtl_String ** pTarget,
|
||||
for (;;)
|
||||
{
|
||||
pTemp = rtl_string_ImplAlloc( nNewLen );
|
||||
OSL_ASSERT(pTemp != nullptr);
|
||||
assert(pTemp != nullptr);
|
||||
nDestBytes = rtl_convertUnicodeToText( hConverter, nullptr,
|
||||
pSource, nLength,
|
||||
pTemp->buffer, nNewLen,
|
||||
@ -230,7 +230,7 @@ static bool rtl_impl_convertUStringToString(rtl_String ** pTarget,
|
||||
if ( nNewLen > nDestBytes+8 )
|
||||
{
|
||||
rtl_String* pTemp2 = rtl_string_ImplAlloc( nDestBytes );
|
||||
OSL_ASSERT(pTemp2 != nullptr);
|
||||
assert(pTemp2 != nullptr);
|
||||
rtl::str::Copy(pTemp2->buffer, pTemp->buffer, nDestBytes);
|
||||
rtl_freeString( pTemp );
|
||||
pTemp = pTemp2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user