From 06b4f1282782a741f26e6a7b981bd4937c7b8b3d Mon Sep 17 00:00:00 2001 From: "shanjian%netscape.com" Date: Fri, 17 Nov 2000 18:13:52 +0000 Subject: [PATCH] #59666, Occurances of uninitialized variables being used before being set. r = nhotta, sr=erik git-svn-id: svn://10.0.0.236/trunk@82735 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/intl/chardet/src/nsCharDetModule.cpp | 2 ++ mozilla/intl/chardet/src/nsPSMDetectors.cpp | 13 ++++++++----- mozilla/intl/uconv/ucvja/nsUnicodeToISO2022JP.cpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mozilla/intl/chardet/src/nsCharDetModule.cpp b/mozilla/intl/chardet/src/nsCharDetModule.cpp index d061492ceb6..8e99796053d 100644 --- a/mozilla/intl/chardet/src/nsCharDetModule.cpp +++ b/mozilla/intl/chardet/src/nsCharDetModule.cpp @@ -221,6 +221,8 @@ nsCharDetModule::GetClassObject(nsIComponentManager *aCompMgr, delete factory; // XXX only works if virtual dtors were used! } } + else + rv = NS_ERROR_FACTORY_NOT_LOADED; return rv; } diff --git a/mozilla/intl/chardet/src/nsPSMDetectors.cpp b/mozilla/intl/chardet/src/nsPSMDetectors.cpp index f24d56e3419..775d44a638d 100644 --- a/mozilla/intl/chardet/src/nsPSMDetectors.cpp +++ b/mozilla/intl/chardet/src/nsPSMDetectors.cpp @@ -439,7 +439,7 @@ void nsPSMDetector::Sample(const char* aBuf, PRUint32 aLen, PRBool aLastChance) printf(" after we receive enough data.\n"); } #endif - PRInt32 bestIdx; + PRInt32 bestIdx = -1; PRInt32 eucCnt=0; float bestScore = 0.0f; for(j = 0; j < mItems; j++) { @@ -462,12 +462,15 @@ void nsPSMDetector::Sample(const char* aBuf, PRUint32 aLen, PRBool aLastChance) } // if(( 0 == eucCnt++) || (bestScore > score )) } // if(nsnull != ...) } // for + if (bestIdx >= 0) + { #ifdef DETECTOR_DEBUG - printf("Based on the statistic, we decide it is %s", - mVerifier[mItemIdx[bestIdx]]->charset); + printf("Based on the statistic, we decide it is %s", + mVerifier[mItemIdx[bestIdx]]->charset); #endif - Report( mVerifier[mItemIdx[bestIdx]]->charset); - mDone = PR_TRUE; + Report( mVerifier[mItemIdx[bestIdx]]->charset); + mDone = PR_TRUE; + } } // if (eucNum == nonUCS2Num) } // if(mRunSampler) } diff --git a/mozilla/intl/uconv/ucvja/nsUnicodeToISO2022JP.cpp b/mozilla/intl/uconv/ucvja/nsUnicodeToISO2022JP.cpp index a3884ffa819..086bedeaf59 100644 --- a/mozilla/intl/uconv/ucvja/nsUnicodeToISO2022JP.cpp +++ b/mozilla/intl/uconv/ucvja/nsUnicodeToISO2022JP.cpp @@ -150,7 +150,7 @@ NS_IMETHODIMP nsUnicodeToISO2022JP::ConvertNoBuffNoErr( char * aDest, PRInt32 * aDestLength) { - nsresult res; + nsresult res = NS_OK; if (mHelper == nsnull) { res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,