Skip to content

Commit f57a4ed

Browse files
committed
Fix infinite recursion in SpaceGroup("bad")
Keep mpCCTbxSpaceGroup as is until after we have new space group. Throw ObjCrystException from SpaceGroup constructor and also from SpaceGroup::ChangeSpaceGroup for invalid space group symbol.
1 parent 5e73d32 commit f57a4ed

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

ObjCryst/ObjCryst/SpaceGroup.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -581,27 +581,29 @@ void SpaceGroup::InitSpaceGroup(const string &spgId)
581581
#endif
582582
try
583583
{
584+
// replace mpCCTbxSpaceGroup only after we get new space group
584585
cctbx::sgtbx::space_group_symbols sgs=cctbx::sgtbx::space_group_symbols(spgId);
585-
if(mpCCTbxSpaceGroup!=0) delete mpCCTbxSpaceGroup;
586-
mpCCTbxSpaceGroup=0;
587-
mpCCTbxSpaceGroup = new cctbx::sgtbx::space_group(sgs);
586+
cctbx::sgtbx::space_group *nsg = new cctbx::sgtbx::space_group(sgs);
587+
assert(nsg);
588+
delete mpCCTbxSpaceGroup;
589+
mpCCTbxSpaceGroup = nsg;
588590
}
589-
catch(exception &ex1)
591+
catch(cctbx::error ex1)
590592
{
591593
try
592594
{
593-
(*fpObjCrystInformUser)("Failed lookup symbol ! try Hall symbol ?");
594-
if(mpCCTbxSpaceGroup!=0) delete mpCCTbxSpaceGroup;
595-
mpCCTbxSpaceGroup=0;
596-
mpCCTbxSpaceGroup = new cctbx::sgtbx::space_group(spgId);
595+
(*fpObjCrystInformUser)("Lookup of '" + spgId + "' symbol failed, trying as Hall symbol.");
596+
// replace mpCCTbxSpaceGroup only after we get new space group
597+
cctbx::sgtbx::space_group *nsg = new cctbx::sgtbx::space_group(spgId);
598+
assert(nsg);
599+
delete mpCCTbxSpaceGroup;
600+
mpCCTbxSpaceGroup = nsg;
597601
}
598-
catch(exception &ex2)
602+
catch(cctbx::error ex2)
599603
{
600604
(*fpObjCrystInformUser)("Could not interpret Spacegroup Symbol:"+spgId);
601-
(*fpObjCrystInformUser)("Reverting to spacegroup symbol:"+mId);
602-
this->InitSpaceGroup(mId);
603-
VFN_DEBUG_EXIT("SpaceGroup::InitSpaceGroup() could not interpret spacegroup:"<<spgId<<":"<<ex1.what()<<":"<<ex2.what(),8)
604-
return;
605+
string emsg = "Space group symbol '" + spgId + "' not recognized";
606+
throw ObjCrystException(emsg);
605607
}
606608
}
607609

0 commit comments

Comments
 (0)