Bug 1668926 - fix resource leak in nsBayesianFilter::​classifyMessage. r=benc

CID 1494443 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.
In nsBayesianFilter::​classifyMessage(Tokenizer &, nsTSubstring<char> const &, nsTArray<unsigned int> &, nsTArray<unsigned int> &, nsIJunkMailClassificationListener *, nsIMsgTraitClassificationListener *, nsIMsgTraitDetailListener *): Leak of memory or pointers to system resources

Differential Revision: https://phabricator.services.mozilla.com/D132777

--HG--
extra : rebase_source : fa28ca85b1e484497822eb8775b51b2e8d9d5778
This commit is contained in:
Magnus Melin 2021-12-06 14:09:11 +02:00
Родитель 7931382298
Коммит 5d4457df12
1 изменённых файлов: 4 добавлений и 5 удалений

Просмотреть файл

@ -1421,6 +1421,10 @@ void nsBayesianFilter::classifyMessage(
nsIJunkMailClassificationListener* listener,
nsIMsgTraitClassificationListener* aTraitListener,
nsIMsgTraitDetailListener* aDetailListener) {
if (aProTraits.Length() != aAntiTraits.Length()) {
NS_ERROR("Each Pro trait needs a matching Anti trait");
return;
}
Token* tokens = tokenizer.copyTokens();
uint32_t tokenCount;
if (!tokens) {
@ -1432,11 +1436,6 @@ void nsBayesianFilter::classifyMessage(
tokenCount = tokenizer.countTokens();
}
if (aProTraits.Length() != aAntiTraits.Length()) {
NS_ERROR("Each Pro trait needs a matching Anti trait");
return;
}
/* this part is similar to the Graham algorithm with some adjustments. */
uint32_t traitCount = aProTraits.Length();