Skip to content

Commit

Permalink
Merge pull request #60 from smithlabcode/check-adaptor-stats-length
Browse files Browse the repository at this point in the history
Checking that we do not access past the end of the adapter summary stats
  • Loading branch information
andrewdavidsmith committed Jul 15, 2024
2 parents 3e4f0ad + 57a1665 commit 4e0ea74
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1952,8 +1952,10 @@ ModuleAdapterContent::write_module(ostream &os) {
for (size_t i = n_pos_calc; i < num_bases; ++i) {
os << i + 1;
for (size_t j = 0; j < num_adapters; ++j)
// ADS: since this is cumulative, pad with final entry
os << "\t" << adapter_pos_pct[j].back();
// ADS: since this is cumulative, pad with final entry; but only
// if that exists...
if (!adapter_pos_pct[j].empty())
os << "\t" << adapter_pos_pct[j].back();
os << "\n";
}
}
Expand Down Expand Up @@ -1995,10 +1997,15 @@ ModuleAdapterContent::make_html_data() {
if (j + 1 < num_bases)
data << ",";
}
for (size_t j = n_pos_calc; j < num_bases; ++j) {
data << adapter_pos_pct[i].back();
if (j + 1 < num_bases)
data << ",";
// ADS: Only write the final entry of the adaptor position
// percentage if that exists. I don't know how we could get here
// if it doesn't, but it's happening.
if (!adapter_pos_pct[i].empty()) {
for (size_t j = n_pos_calc; j < num_bases; ++j) {
data << adapter_pos_pct[i].back();
if (j + 1 < num_bases)
data << ",";
}
}

data << "]";
Expand Down

0 comments on commit 4e0ea74

Please sign in to comment.