Fix undefined behavior from empty container access and other bugs #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Static analysis and code review identified multiple instances of undefined behavior from accessing empty containers, plus a few other bugs.
Empty container access guards
molecule.h:is_protein()now checksatoms_->empty()before accessing[0]bonds.cpp:get_bonds()andupdate_bonds()return early on empty inputpqr.cpp,cif.cpp,mol2.cpp: Guardmolecules()[0]andatoms()[0]accesspdb.cpp: ThrowFileExceptionwhenstructure.modelsis emptyOther fixes
ee_method.cpp: Division by zero guard in cover solver:if (charges_count[i] > 0)common.cpp: Early return inget_element_symbol()for empty stringspython.cpp: Rename loop varcharges→chgto avoid shadowing parameteroptions.cpp:std::print→std::printlnfor proper newlineExample fix
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https /usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.