зеркало из https://github.com/mozilla/pjs.git
Bug #240819 --> Crash in mail.dll when checking mail - TB073 [@ nsTransform2D::SetToIdentity ]
Fix a potential divide by zero floating point operation in the bayesian algorithm to hopefully prevent a top crash.
This commit is contained in:
Родитель
26b7c53bd7
Коммит
03878f136f
|
@ -979,7 +979,14 @@ void nsBayesianFilter::classifyMessage(Tokenizer& tokenizer, const char* message
|
|||
double hamcount = ((t != NULL) ? t->mCount : 0);
|
||||
t = mBadTokens.get(word);
|
||||
double spamcount = ((t != NULL) ? t->mCount : 0);
|
||||
prob = (spamcount / nbad) / ( hamcount / ngood + spamcount / nbad);
|
||||
|
||||
// if hamcount and spam count are both 0, we could end up with a divide by 0 error,
|
||||
// tread carefully here. (Bug #240819)
|
||||
double probDenom = (hamcount *nbad + spamcount*ngood);
|
||||
if (probDenom == 0.0) // nGood and nbad are known to be non zero or we wouldn't be here
|
||||
probDenom = nbad + ngood; // error case use a value of 1 for hamcount and spamcount if they are both zero.
|
||||
|
||||
prob = (spamcount * ngood)/probDenom;
|
||||
double n = hamcount + spamcount;
|
||||
prob = (0.225 + n * prob) / (.45 + n);
|
||||
double distance = PR_ABS(prob - 0.5);
|
||||
|
|
Загрузка…
Ссылка в новой задаче