Classify: Run sort only for more than one element

This fixes calls of qsort with a nullptr argument (reported by sanitizers).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2020-06-20 21:37:57 +02:00
parent 5a698c278d
commit 6f6100ff9f

View File

@ -1376,7 +1376,9 @@ int Classify::CharNormTrainingSample(bool pruner_only,
for (int i = 0; i < adapt_results->match.size(); i++) {
results->push_back(adapt_results->match[i]);
}
results->sort(&UnicharRating::SortDescendingRating);
if (results->size() > 1) {
results->sort(&UnicharRating::SortDescendingRating);
}
}
delete [] char_norm_array;
delete adapt_results;