mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
Avoid a segfault in CoordGen when a double bond has stereo spec but no stereo atoms (#8415)
* avoid a segfault in CoordGen when a double bond has stereo spec but no stereo atoms * changes in response to review --------- Co-authored-by: ptosco <paolo.tosco@novartis.com>
This commit is contained in:
@@ -2337,3 +2337,19 @@ M END)CTAB"_ctab;
|
||||
CHECK_THAT(ctd.x, Catch::Matchers::WithinAbs(0.0, 1.0e-4));
|
||||
CHECK_THAT(ctd.y, Catch::Matchers::WithinAbs(0.0, 1.0e-4));
|
||||
}
|
||||
|
||||
#ifdef RDK_BUILD_COORDGEN_SUPPORT
|
||||
TEST_CASE("CoordGen should not segfault when bond has stereo spec but no stereo atoms") {
|
||||
auto m = "C=C1C=CC(=O)CC1"_smiles;
|
||||
REQUIRE(m);
|
||||
CHECK(m->getNumBonds() == 8);
|
||||
auto b = m->getBondWithIdx(0);
|
||||
CHECK(b->getBondType() == Bond::DOUBLE);
|
||||
b->setStereo(Bond::STEREOZ);
|
||||
CHECK(b->getStereoAtoms().empty());
|
||||
RDDepict::preferCoordGen = true;
|
||||
RDDepict::compute2DCoords(*m);
|
||||
RDDepict::preferCoordGen = false;
|
||||
CHECK(m->getNumConformers() == 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
4
External/CoordGen/CoordGen.h
vendored
4
External/CoordGen/CoordGen.h
vendored
@@ -154,8 +154,10 @@ unsigned int addCoords(T &mol, const CoordGenParams *params = nullptr) {
|
||||
auto obnd = *bndit;
|
||||
if (obnd->getBondType() != Bond::DOUBLE ||
|
||||
obnd->getStereo() <= Bond::STEREOANY ||
|
||||
obnd->getStereo() > Bond::STEREOTRANS)
|
||||
obnd->getStereo() > Bond::STEREOTRANS ||
|
||||
obnd->getStereoAtoms().size() < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sketcherMinimizerBondStereoInfo sinfo;
|
||||
sinfo.atom1 = ats[obnd->getStereoAtoms()[0]];
|
||||
|
||||
Reference in New Issue
Block a user