From 477c5504e05f9031449cdbf62bf329eac427cb0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Tue, 20 Jan 2026 15:34:46 +0100 Subject: [PATCH] coins: replace `std::distance` with unambiguous pointer subtraction Avoid calling `std::distance` on null pointers in `PoolResource::AllocateChunk`. Compute remaining bytes with `m_available_memory_end - m_available_memory_it` instead, which is well-defined to be `0` when both are `nullptr`. Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> --- src/support/allocators/pool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/support/allocators/pool.h b/src/support/allocators/pool.h index abca09ad901..d4ce68b970e 100644 --- a/src/support/allocators/pool.h +++ b/src/support/allocators/pool.h @@ -155,7 +155,7 @@ class PoolResource final void AllocateChunk() { // if there is still any available memory left, put it into the freelist. - size_t remaining_available_bytes = std::distance(m_available_memory_it, m_available_memory_end); + size_t remaining_available_bytes = m_available_memory_end - m_available_memory_it; if (0 != remaining_available_bytes) { ASAN_UNPOISON_MEMORY_REGION(m_available_memory_it, sizeof(ListNode)); PlacementAddToList(m_available_memory_it, m_free_lists[remaining_available_bytes / ELEM_ALIGN_BYTES]);