Avoid bad_alloc for variable length features

git-svn-id: http://svn.statmt.org/repository/mira@3837 cc96ff50-19ce-11e0-b349-13d7f0bd23df
This commit is contained in:
bhaddow 2011-03-18 15:37:15 +00:00 committed by Ondrej Bojar
parent b7971689cb
commit 14b35072bc

View File

@ -200,7 +200,9 @@ public:
//! return a vector of all the scores associated with a certain ScoreProducer
std::vector<float> GetScoresForProducer(const ScoreProducer* sp) const
{
std::vector<float> res(sp->GetNumScoreComponents());
size_t components = sp->GetNumScoreComponents();
if (components == ScoreProducer::unlimited) return std::vector<float>();
std::vector<float> res(components);
const std::vector<FName>& names = sp->GetFeatureNames();
for (size_t i = 0; i < names.size(); ++i) {
res[i] = m_scores[names[i]];