From b1f03cb6975ee4bde6d8c9450ea55f111cc36ac1 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 24 Oct 2016 16:12:31 +0200 Subject: [PATCH] classify/adaptmatch: Fix memory leak Coverity report: CID 1340280 (#1 of 1): Resource leak (RESOURCE_LEAK) 7. leaked_storage: Variable FloatFeatures going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil --- classify/adaptmatch.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classify/adaptmatch.cpp b/classify/adaptmatch.cpp index 9ab95a68b9..6e995c2159 100644 --- a/classify/adaptmatch.cpp +++ b/classify/adaptmatch.cpp @@ -907,8 +907,10 @@ void Classify::AdaptToChar(TBLOB* Blob, CLASS_ID ClassId, int FontinfoId, IClass = ClassForClassId(adaptive_templates->Templates, ClassId); NumFeatures = GetAdaptiveFeatures(Blob, IntFeatures, &FloatFeatures); - if (NumFeatures <= 0) + if (NumFeatures <= 0) { + FreeFeatureSet(FloatFeatures); return; + } // Only match configs with the matching font. BIT_VECTOR MatchingFontConfigs = NewBitVector(MAX_NUM_PROTOS);