From c8f5fd14a1fbdaaa9e1216dd5163d1f5c1b5ff27 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 27 Nov 2012 09:38:29 +0200 Subject: [PATCH] Fix a crash if the linear program contains an empty column --- source/layout.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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; } -- 2.43.0