From: Mikko Rasa Date: Tue, 27 Nov 2012 07:38:29 +0000 (+0200) Subject: Fix a crash if the linear program contains an empty column X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c8f5fd14a1fbdaaa9e1216dd5163d1f5c1b5ff27;p=libs%2Fgltk.git Fix a crash if the linear program contains an empty column --- diff --git a/source/layout.cpp b/source/layout.cpp index b95ab92..74b33f0 100644 --- a/source/layout.cpp +++ b/source/layout.cpp @@ -383,10 +383,14 @@ bool Layout::LinearProgram::solve() pricing out the constraint rows. */ for(vector::iterator i=columns.begin(); i!=columns.end(); ++i) { - float objective = i->values.front(); - i->values.front() = 0.0f; - for(vector::iterator j=i->values.begin(); j!=i->values.end(); ++j) - i->values.front() += *j; + float objective = 0.0f; + if(!i->values.empty()) + { + objective = i->values.front(); + i->values.front() = 0.0f; + for(vector::iterator j=i->values.begin(); j!=i->values.end(); ++j) + i->values.front() += *j; + } i->values.resize(n_rows+1, 0.0f); i->values.back() = objective; }