diff --git a/src/core/codeconvert.cpp b/src/core/codeconvert.cpp index 07d40f2..3d926d5 100644 --- a/src/core/codeconvert.cpp +++ b/src/core/codeconvert.cpp @@ -1323,7 +1323,9 @@ cWcharIs32BitUcs2Converterer::Convert( throw eConverterFatal( TSS_GetString( cCore, core::STR_ERR_ISNULL ) ); // cast our dbchar_t to wchar_t's first - ntwcs_t pwzBuffer = new wchar_t[ nCount + 1 ]; + std::vector buf(nCount+1); + wchar_t* pwzBuffer = &buf[0]; + for( size_t n = 0; n < nCount; n++ ) pwzBuffer[n] = pwz[n]; pwzBuffer[nCount] = 0x00; // null terminate @@ -1358,7 +1360,8 @@ cWcharIs32BitUcs2Converterer::Convert( throw eConverterFatal( TSS_GetString( cCore, core::STR_ERR_ISNULL ) ); // mb to wc to a buffer of wide chars then.... - wchar_t* pwzBuffer = new wchar_t[ nCount ]; + std::vector buf(nCount); + wchar_t* pwzBuffer = &buf[0]; int nConv = tss_mbstowcs( pwzBuffer, pbz, nCount ); if ( nConv == -1 ) @@ -1451,22 +1454,26 @@ cGoodEnoughConverterer::Convert( throw eConverterFatal( TSS_GetString( cCore, core::STR_ERR_ISNULL ) ); char* at = pbz; - const dbchar_t* dat = pwz; - while ( *dat ) + + if (pwz) { - if( *dat > 0xFF ) + const dbchar_t* dat = pwz; + while ( *dat ) { - *at = cConvertUtil::ConvertNonChar( *dat ); + if( *dat > 0xFF ) + { + *at = cConvertUtil::ConvertNonChar( *dat ); + } + else + { + *at = (char)*dat; + } + + at++; + dat++; } - else - { - *at = (char)*dat; - } - - at++; - dat++; } - + *at = 0x00; return( (size_t)at - (size_t)pbz ); @@ -1481,23 +1488,26 @@ cGoodEnoughConverterer::Convert( if ( pwz == 0 || ( pbz == 0 && nBytes ) ) throw eConverterFatal( TSS_GetString( cCore, core::STR_ERR_ISNULL ) ); - const char* at = pbz; dbchar_t* dat = pwz; - while ( *at ) + + if (pbz) { - if( (unsigned char)*at > (unsigned char)0x7Fu ) + const char* at = pbz; + while ( *at ) { - *dat = cConvertUtil::ConvertNonChar( *at ); - } - else - { - *dat = (uint16)(unsigned char)*at; - } + if( (unsigned char)*at > (unsigned char)0x7Fu ) + { + *dat = cConvertUtil::ConvertNonChar( *at ); + } + else + { + *dat = (uint16)(unsigned char)*at; + } - dat++; - at++; + dat++; + at++; + } } - *dat = 0x0000; return( ( (size_t)dat - (size_t)pwz ) / sizeof( dbchar_t ) ); diff --git a/src/core/unixfsservices.cpp b/src/core/unixfsservices.cpp index b2b4ef5..5da6073 100644 --- a/src/core/unixfsservices.cpp +++ b/src/core/unixfsservices.cpp @@ -1105,8 +1105,8 @@ bool util_GetNextPathElement( const TSTRING& strPathC, TSTRING& strElem, int ind TSTRING strPath = strPathC; // writable local version bool fMoreSeps = true; - TSTRING::size_type firstSep, nextSep, nextNonSep; - firstSep = nextSep = nextNonSep = (TSTRING::size_type)-1; + TSTRING::size_type nextSep, nextNonSep; + nextSep = nextNonSep = (TSTRING::size_type)-1; for( int i = 0; i <= index && fMoreSeps; i++ ) { // go past leading separators diff --git a/src/fco/fcopropvector.cpp b/src/fco/fcopropvector.cpp index 000ed41..449aaff 100644 --- a/src/fco/fcopropvector.cpp +++ b/src/fco/fcopropvector.cpp @@ -260,8 +260,12 @@ int cFCOPropVector::SetSize(int max) } else //mpBuf!=NULL && max>msBitlength { - (*mpBuf).resize (((max/msBitlength)+1), 0); - return mSize = ((*mpBuf).capacity() * msBitlength); + if (mpBuf) + { + (*mpBuf).resize (((max/msBitlength)+1), 0); + mSize = ((*mpBuf).capacity() * msBitlength); + } + return mSize; } } diff --git a/src/tripwire/integritycheck.cpp b/src/tripwire/integritycheck.cpp index 4d6a603..8dc7147 100644 --- a/src/tripwire/integritycheck.cpp +++ b/src/tripwire/integritycheck.cpp @@ -353,12 +353,15 @@ void cIntegrityCheck::ProcessDir( cDbDataSourceIter dbIter, iFCODataSourceIter* if( dbIter.Done() ) { ASSERT( pIter != 0); - d.TraceDetail( "Examining and %s\n", pIter->GetName().AsString().c_str() ); - // - // these are all new entries, add them to the "Added" set... - // - ProcessAddedFCO( dbIter, pIter ); - pIter->Next(); + if (pIter) + { + d.TraceDetail( "Examining and %s\n", pIter->GetName().AsString().c_str() ); + // + // these are all new entries, add them to the "Added" set... + // + ProcessAddedFCO( dbIter, pIter ); + pIter->Next(); + } } else if( ! pIter ) { diff --git a/src/tripwire/mailmessage.h b/src/tripwire/mailmessage.h index 498df66..b8ef197 100644 --- a/src/tripwire/mailmessage.h +++ b/src/tripwire/mailmessage.h @@ -273,10 +273,6 @@ private: void SendInit();// throw (eMailMessageError) // opens a pipe to sendmail and writes the header. - FILE* GetFilePointer() const; - // returns a pointer to the current file pointer. Only valid between - // SendInit() and SendFinit() - void SendFinit(); //throw (eMailMessageError) // closes the file descriptor, sending the rest of the message diff --git a/src/tripwire/pipedmailmessage.cpp b/src/tripwire/pipedmailmessage.cpp index 9fbb753..15cd432 100644 --- a/src/tripwire/pipedmailmessage.cpp +++ b/src/tripwire/pipedmailmessage.cpp @@ -80,8 +80,7 @@ bool cPipedMailMessage::Send() SendInit(); - FILE* sendPipe = GetFilePointer(); - ASSERT( sendPipe != 0 ); + ASSERT( mpFile != 0 ); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Get Body and Attachments //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -213,8 +212,3 @@ void cPipedMailMessage::SendFinit() //throw ( eMailMessageError ) } -FILE* cPipedMailMessage::GetFilePointer() const -{ - return mpFile; -} - diff --git a/src/tw/dbdebug.cpp b/src/tw/dbdebug.cpp index c5b0220..2f5318a 100644 --- a/src/tw/dbdebug.cpp +++ b/src/tw/dbdebug.cpp @@ -450,6 +450,7 @@ void cDbDebug::OutputResults( void ) // Begin code for manipulating Database -- This is just a straight port from the DbExplore code. It's presence is // purely for convenience, and for debugging this class. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/* static inline bool IsSpace( TCHAR c ) { return ( (c == _T(' ')) || (c == _T('\t')) || (c == _T('\r')) || (c == _T('\n')) || (c == _T('\0')) ); @@ -460,7 +461,6 @@ static inline bool IsEnd( TCHAR c ) return ( (c == _T('\0')) ); } -/* /////////////////////////////////////////////////////////////////////////////// // util_PrintFCO /////////////////////////////////////////////////////////////////////////////// diff --git a/src/tw/fcoreport.cpp b/src/tw/fcoreport.cpp index 9084cac..79af470 100644 --- a/src/tw/fcoreport.cpp +++ b/src/tw/fcoreport.cpp @@ -514,13 +514,6 @@ cFCOReportChangeIter::cFCOReportChangeIter(const cFCOReportSpecIter& specIter) SetSpecIter(specIter); } -cFCOReportChangeIter::cFCOReportChangeIter() -{ - mpData = new cFCOReportChangeIter_i; - mpData->mpList = 0; - mpData->mIter = mpData->mpList->begin(); -} - cFCOReportChangeIter::cFCOReportChangeIter(const cFCOReportChangeIter& rhs) { mpData = new cFCOReportChangeIter_i; diff --git a/src/tw/fcoreport.h b/src/tw/fcoreport.h index 5c578b6..7da27d1 100644 --- a/src/tw/fcoreport.h +++ b/src/tw/fcoreport.h @@ -227,7 +227,6 @@ class cFCOReportChangeIter { public: cFCOReportChangeIter(const cFCOReportSpecIter& specIter); - cFCOReportChangeIter(); cFCOReportChangeIter(const cFCOReportChangeIter& rhs); ~cFCOReportChangeIter(); @@ -251,6 +250,8 @@ public: const cFCOPropVector& GetChangeVector() const; private: + cFCOReportChangeIter() {} + cFCOReportChangeIter_i* mpData; // TODO -- if it turns out that we are creating a lot of these, we should consider // making a pool of them. diff --git a/src/tw/textreportviewer.cpp b/src/tw/textreportviewer.cpp index 05eac5f..82c9bda 100644 --- a/src/tw/textreportviewer.cpp +++ b/src/tw/textreportviewer.cpp @@ -1519,6 +1519,9 @@ void cTextReportViewer::DisplayChangedProps( const iFCO* const pfcoOld, const iF void cTextReportViewer::OutputAddedSummary( const cFCOReportSpecIter& ri, FCOList* pFCONameList ) { + if (!pFCONameList) + return; + if( ! ri.GetAddedSet()->IsEmpty() ) { (*mpOut) << TSS_GetString( cTW, tw::STR_ADDED ) << _T(":") << endl; @@ -1538,7 +1541,10 @@ void cTextReportViewer::OutputAddedSummary( const cFCOReportSpecIter& ri, FCOLis } void cTextReportViewer::OutputRemovedSummary( const cFCOReportSpecIter& ri, FCOList* pFCONameList) -{ +{ + if (!pFCONameList) + return; + if( ! ri.GetRemovedSet()->IsEmpty() ) { (*mpOut) << TSS_GetString( cTW, tw::STR_REMOVED ) << _T(":") << endl; @@ -1558,7 +1564,10 @@ void cTextReportViewer::OutputRemovedSummary( const cFCOReportSpecIter& ri, FCOL } void cTextReportViewer::OutputChangedSummary( const cFCOReportSpecIter& ri, FCOList* pFCONameList ) -{ +{ + if (!pFCONameList) + return; + if( ri.GetNumChanged() > 0 ) { (*mpOut) << TSS_GetString( cTW, tw::STR_CHANGED ) << _T(":") << endl; diff --git a/src/twadmin/twadmincl.cpp b/src/twadmin/twadmincl.cpp index f259640..17db7e2 100644 --- a/src/twadmin/twadmincl.cpp +++ b/src/twadmin/twadmincl.cpp @@ -1556,16 +1556,12 @@ int cTWAModeExamine::Execute(cErrorQueue* pQueue) // Output the keys that decrypt the file. iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL, TSS_GetString(cTWAdmin, twadmin::STR_KEYS_DECRYPT ).c_str()); iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL, TSS_GetString(cTW, tw::STR_NEWLINE ).c_str()); - - bool siteDecrypts = false, localDecrypts = false; if (siteKey.KeysLoaded()) try { if (manip.TestDecryption(*siteKey.GetPublicKey(), false) != false) { - siteDecrypts = true; - iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, TSS_GetString(cTWAdmin, twadmin::STR_SITEKEYFILE ).c_str()); iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, cDisplayEncoder::EncodeInline( mSiteKeyFile ).c_str()); @@ -1579,7 +1575,6 @@ int cTWAModeExamine::Execute(cErrorQueue* pQueue) { if (manip.TestDecryption(*localKey.GetPublicKey(), false) != false) { - localDecrypts = true; iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, TSS_GetString(cTWAdmin, twadmin::STR_LOCALKEYFILE ).c_str()); iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, cDisplayEncoder::EncodeInline( mLocalKeyFile ).c_str()); @@ -1834,7 +1829,6 @@ int cTWAModeGenerateKeys::Execute(cErrorQueue* pQueue) // if(! bPrintedPassphraseHint) { - bPrintedPassphraseHint = true; iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, TSS_GetString(cTWAdmin, twadmin::STR_PASSPHRASE_HINT).c_str() ); } @@ -2162,7 +2156,6 @@ int cTWAModeChangePassphrases::Execute(cErrorQueue* pQueue) // if(! bPrintedPassphraseHint) { - bPrintedPassphraseHint = true; iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, TSS_GetString(cTWAdmin, twadmin::STR_PASSPHRASE_HINT).c_str() ); }