From 5d4457df125160f021ae7247994165475a746507 Mon Sep 17 00:00:00 2001 From: Magnus Melin Date: Mon, 6 Dec 2021 14:09:11 +0200 Subject: [PATCH] =?UTF-8?q?Bug=201668926=20-=20fix=20resource=20leak=20in?= =?UTF-8?q?=20nsBayesianFilter::=E2=80=8BclassifyMessage.=20r=3Dbenc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 const &, nsTArray &, nsTArray &, nsIJunkMailClassificationListener *, nsIMsgTraitClassificationListener *, nsIMsgTraitDetailListener *): Leak of memory or pointers to system resources Differential Revision: https://phabricator.services.mozilla.com/D132777 --HG-- extra : rebase_source : fa28ca85b1e484497822eb8775b51b2e8d9d5778 --- .../extensions/bayesian-spam-filter/nsBayesianFilter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mailnews/extensions/bayesian-spam-filter/nsBayesianFilter.cpp b/mailnews/extensions/bayesian-spam-filter/nsBayesianFilter.cpp index abcee8b268..d33c561f67 100644 --- a/mailnews/extensions/bayesian-spam-filter/nsBayesianFilter.cpp +++ b/mailnews/extensions/bayesian-spam-filter/nsBayesianFilter.cpp @@ -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();