From 0a099ad96acc0f16dfbb477d7ce16b27d4baec5d Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Wed, 28 Oct 2026 12:55:27 -0700 Subject: [PATCH 1/3] src/fastq_bgzf_file.cpp: preventing division by zero --- src/fastq_bgzf_file.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fastq_bgzf_file.cpp b/src/fastq_bgzf_file.cpp index 91d30a7..65d4396 100644 --- a/src/fastq_bgzf_file.cpp +++ b/src/fastq_bgzf_file.cpp @@ -144,8 +144,8 @@ fastq_bgzf_file::get_chunks(std::int64_t n_chunks, const auto n_bytes_available = output_last; n_chunks = std::min((n_bytes_available + min_chunk_size - 1) / min_chunk_size, n_chunks); - const auto [chunk_size, remainder] = std::div(n_bytes_available, n_chunks); - assert(n_chunks > 0); + const auto [chunk_size, remainder] = + std::div(n_bytes_available, std::max(1L, n_chunks)); std::int64_t start_pos{}; std::int64_t chunk_end{}; for (const auto chunk_idx : std::views::iota(0, n_chunks)) { From 11354e265b13dde5f22a1408373cc67ca3a74947 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Wed, 28 Oct 2026 13:18:10 -0700 Subject: [PATCH 2/3] src/falco.cpp: ensuring buffer size is correct --- src/falco.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/falco.cpp b/src/falco.cpp index a94d478..87424fb 100644 --- a/src/falco.cpp +++ b/src/falco.cpp @@ -536,7 +536,8 @@ main(int argc, char *argv[]) { // restrict buffer size to avoid using a possibly harmful amount of memory const auto get_sz = [](const auto &i) { return i.size; }; const auto max_sz = std::ranges::max(std::views::transform(infos, get_sz)); - buffer_size = buffer_size < max_sz ? buffer_size : min_buf_size; + buffer_size = + buffer_size < max_sz ? buffer_size : std::max(max_sz, min_buf_size); const auto min_buffer_size = get_min_buffer_size(max_read_length); if (std::cmp_greater(min_buffer_size, buffer_size)) { From d281affeb693a63f9635f73dd819743a8754c443 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Wed, 28 Oct 2026 13:33:15 -0700 Subject: [PATCH 3/3] src/fastq_bgzf_file.cpp: fixing macos compiler complaint about type when comparing n_chunks with 1 --- src/fastq_bgzf_file.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fastq_bgzf_file.cpp b/src/fastq_bgzf_file.cpp index 65d4396..719e928 100644 --- a/src/fastq_bgzf_file.cpp +++ b/src/fastq_bgzf_file.cpp @@ -144,8 +144,8 @@ fastq_bgzf_file::get_chunks(std::int64_t n_chunks, const auto n_bytes_available = output_last; n_chunks = std::min((n_bytes_available + min_chunk_size - 1) / min_chunk_size, n_chunks); - const auto [chunk_size, remainder] = - std::div(n_bytes_available, std::max(1L, n_chunks)); + const auto [chunk_size, remainder] = std::div( + n_bytes_available, std::max(static_cast(1), n_chunks)); std::int64_t start_pos{}; std::int64_t chunk_end{}; for (const auto chunk_idx : std::views::iota(0, n_chunks)) {