Skip to content

Commit

Permalink
Don't try to validate in annotateDSSP when the validator is not set (…
Browse files Browse the repository at this point in the history
…nullptr)

Fixes a segfault if one passes in a Cif datablock that didn't have `cif::pdb::reconstruct_pdbx(cif_file);` called on it.
  • Loading branch information
Augustin-Zidek authored Sep 26, 2024
1 parent 778d0ad commit 3d835b8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions libdssp/src/dssp-io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,12 +747,14 @@ void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, bool wr
{
using namespace std::literals;

auto &validator = const_cast<cif::validator &>(*db.get_validator());
if (validator.get_validator_for_category("dssp_struct_summary") == nullptr)
{
auto dssp_extension = cif::load_resource("dssp-extension.dic");
if (dssp_extension)
cif::extend_dictionary(validator, *dssp_extension);
if (db.get_validator() != nullptr) {
auto &validator = const_cast<cif::validator &>(*db.get_validator());
if (validator.get_validator_for_category("dssp_struct_summary") == nullptr)
{
auto dssp_extension = cif::load_resource("dssp-extension.dic");
if (dssp_extension)
cif::extend_dictionary(validator, *dssp_extension);
}
}

if (dssp.empty())
Expand Down

0 comments on commit 3d835b8

Please sign in to comment.