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>
This commit is contained in:
Lőrinc
2026-01-20 15:34:46 +01:00
parent c84c752506
commit 477c5504e0

View File

@@ -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]);