allocator_avl: return 0 for improper size_at call

In case the given address is not the start of a block bail instead of
making improper size assumptions.

Issue #4325.
This commit is contained in:
Josef Söntgen 2021-11-12 16:29:42 +01:00 committed by Christian Helmuth
parent 49bf58a2ae
commit 98385a7658

View File

@ -401,6 +401,9 @@ size_t Allocator_avl_base::size_at(void const *addr) const
/* lookup corresponding block */
Block *b = _find_by_address(reinterpret_cast<addr_t>(addr));
if (b && (b->addr() != (addr_t)addr))
return 0;
return (b && b->used()) ? b->size() : 0;
}