From a404342559fb87216754f6cf0607b69f395f3dcf Mon Sep 17 00:00:00 2001 From: Jared Wolff Date: Thu, 5 Mar 2026 16:20:52 -0500 Subject: [PATCH] fix(pagination): prevent usize underflow when total_pages is zero When there are no items, total_pages is 0 and `total_pages - 1` causes a subtract-with-overflow panic on usize. Guard the subtraction with a `total_pages > 0` check. --- src/application/dtos/pagination.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application/dtos/pagination.rs b/src/application/dtos/pagination.rs index 67fac807..802dfe06 100755 --- a/src/application/dtos/pagination.rs +++ b/src/application/dtos/pagination.rs @@ -93,7 +93,7 @@ impl PaginatedResponseDto { page_size, total_items, total_pages, - has_next: page < total_pages - 1, + has_next: total_pages > 0 && page < total_pages - 1, has_prev: page > 0, };