From 79564f714f6f2b1df11e4359097cf63452922961 Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Mon, 24 Jun 2024 21:02:24 -0400 Subject: [PATCH] Fix divide by zero in subaddresses n_maj (#114) --- src/rest_server.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rest_server.cpp b/src/rest_server.cpp index 6efa4d7..c9e9d50 100644 --- a/src/rest_server.cpp +++ b/src/rest_server.cpp @@ -759,16 +759,16 @@ namespace lws const std::uint32_t n_major = req.n_maj.value_or(50); const std::uint32_t n_minor = req.n_min.value_or(500); const bool get_all = req.get_all.value_or(true); - - if (std::numeric_limits::max() / n_major < n_minor) - return {lws::error::max_subaddresses}; - if (options.max_subaddresses < n_major * n_minor) - return {lws::error::max_subaddresses}; - + std::vector new_ranges; std::vector all_ranges; if (n_major && n_minor) { + if (std::numeric_limits::max() / n_major < n_minor) + return {lws::error::max_subaddresses}; + if (options.max_subaddresses < n_major * n_minor) + return {lws::error::max_subaddresses}; + std::vector ranges; ranges.reserve(n_major); for (std::uint64_t elem : boost::counting_range(std::uint64_t(major_i), std::uint64_t(major_i) + n_major))