From 9b5ba4525b2b23b487911518c78a822aa9e6b17a Mon Sep 17 00:00:00 2001 From: John Stone Date: Tue, 16 Jul 2024 12:15:05 +0200 Subject: [PATCH] Bugfix for the CIGAR out of bounds issue in correct/features.cpp. --- dorado/correct/features.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dorado/correct/features.cpp b/dorado/correct/features.cpp index 47afb7a65..dddbe9d82 100644 --- a/dorado/correct/features.cpp +++ b/dorado/correct/features.cpp @@ -248,8 +248,10 @@ std::tuple get_features_for_window( qseq = utils::reverse_complement(qseq); std::reverse(qqual.begin(), qqual.end()); } - int cigar_len = overlap.cigar_end_idx - overlap.cigar_start_idx + 1; - int cigar_end = std::min((int)cigar.size(), cigar_len); + + const int cigar_len_total = static_cast(std::size(cigar)); + const int cigar_len = overlap.cigar_end_idx - overlap.cigar_start_idx + 1; + const int cigar_end = std::min(cigar_len_total - overlap.cigar_start_idx, cigar_len); uint8_t gap = fwd ? '*' : '#';