Skip to content

mip: Fix use-after-move in HighsLpRelaxation::loadModel#2713

Merged
jajhall merged 1 commit intoERGO-Code:latestfrom
stratakis:use_after_move
Dec 26, 2025
Merged

mip: Fix use-after-move in HighsLpRelaxation::loadModel#2713
jajhall merged 1 commit intoERGO-Code:latestfrom
stratakis:use_after_move

Conversation

@stratakis
Copy link
Copy Markdown
Contributor

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.

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.
@stratakis
Copy link
Copy Markdown
Contributor Author

The was uncovered during a Coverity scan on scipy:

 4. scipy-1.16.2/subprojects/highs/src/mip/HighsLpRelaxation.cpp:227:3: move: "lpmodel" is moved (indicated by "std::move(lpmodel)").
5. scipy-1.16.2/subprojects/highs/src/mip/HighsLpRelaxation.cpp:228:3: use_after_move: "lpmodel" is used after it has been already moved.
   226|     lpsolver.clearModel();
   227|     lpsolver.passModel(std::move(lpmodel));
   228|->   colLbBuffer.resize(lpmodel.num_col_);
   229|     colUbBuffer.resize(lpmodel.num_col_);
   230|   }

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.33%. Comparing base (c29f3ed) to head (eedc74e).
⚠️ Report is 387 commits behind head on latest.

Additional details and impacted files
@@            Coverage Diff             @@
##           latest    #2713      +/-   ##
==========================================
+ Coverage   81.06%   81.33%   +0.26%     
==========================================
  Files         347      349       +2     
  Lines       85219    86135     +916     
==========================================
+ Hits        69083    70054     +971     
+ Misses      16136    16081      -55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@jajhall jajhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't known to have caused any problems, bit it does no harm

@jajhall jajhall merged commit 367cdba into ERGO-Code:latest Dec 26, 2025
254 of 255 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants