Skip to content

Commit eedc74e

Browse files
committed
mip: Fix use-after-move in HighsLpRelaxation::loadModel
Save lpmodel.num_col_ before passing lpmodel via std::move to lpsolver.passModel(). After the move, lpmodel is in a valid but unspecified state, making access to its members undefined behavior. Found by Coverity static analysis.
1 parent 96f998e commit eedc74e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

highs/mip/HighsLpRelaxation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,12 @@ void HighsLpRelaxation::loadModel() {
237237
for (HighsInt i = 0; i != lpmodel.num_row_; ++i)
238238
lprows.push_back(LpRow::model(i));
239239
lpmodel.integrality_.clear();
240+
HighsInt num_col = lpmodel.num_col_;
240241
lpsolver.clearSolver();
241242
lpsolver.clearModel();
242243
lpsolver.passModel(std::move(lpmodel));
243-
colLbBuffer.resize(lpmodel.num_col_);
244-
colUbBuffer.resize(lpmodel.num_col_);
244+
colLbBuffer.resize(num_col);
245+
colUbBuffer.resize(num_col);
245246
}
246247

247248
void HighsLpRelaxation::resetToGlobalDomain() {

0 commit comments

Comments
 (0)