Skip to content

Commit

Permalink
Validates FORMAT field sizes before writing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonl committed Jun 30, 2023
1 parent 9ba1ab1 commit 78f94e2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/savvy/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ namespace savvy
pbwt_format_pointers.back() = &sort_context_.format_contexts[it->first][it->second.size()];
}

if (it->second.size() == 0 || (it->second.size() % n_samples_) != 0)
{
std::cerr << "Error: FMT/" << it->first << " is either empty or not divisible by the number of samples" << std::endl;
ofs_.setstate(ofs_.rdstate() | std::ios::failbit);
return *this;
}


if (file_format_ == format::sav2 || it->first != "PH")
++n_fmt;
}
Expand Down

0 comments on commit 78f94e2

Please sign in to comment.