-
Notifications
You must be signed in to change notification settings - Fork 845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MolDraw2D::drawMolecules() should not crash on null molecules #5503
Conversation
@@ -231,12 +232,13 @@ void MolDraw2D::drawMolecules( | |||
drawMols_.back()->setOffsets(col * panelWidth(), row * panelHeight()); | |||
drawMols_.back()->createDrawObjects(); | |||
if (drawMols_.back()->getScale() < drawMols_[minScaleMol]->getScale()) { | |||
minScaleMol = i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, sorry.
You could perhaps use drawMols_.size()-1 here rather than carrying j around. It might be a bit more immediately obvious what the intention was.
Although you probably need to change the lines just above that where it updates the rows and columns to also use j, in which case ignore the bit above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DavidACosgrove Thanks for your review, I think it is a good idea and I have made the change you suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…5503) * MolDraw2D::drawMolecules() should not crash on null molecules * changes in response to review Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
…5503) * MolDraw2D::drawMolecules() should not crash on null molecules * changes in response to review Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
…5503) * MolDraw2D::drawMolecules() should not crash on null molecules * changes in response to review Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
This bug was originally reported by Richard Lewis.
MolDraw2D::drawMolecules()
under certain conditions will attempt to access non-existent vector items and hence segfault.This simple PR fixes the problem and adds a test.