Improve check_bounds init check.

This commit is contained in:
Matthew Parkinson
2022-01-10 10:34:28 +00:00
committed by Matthew Parkinson
parent 419347ba4a
commit ef64f6c31b
5 changed files with 26 additions and 2 deletions

View File

@@ -772,6 +772,16 @@ namespace snmalloc
#endif
}
bool check_bounds(const void* p, size_t s)
{
auto ls = core_alloc->backend_state_ptr();
if (SNMALLOC_LIKELY(SharedStateHandle::Pagemap::is_initialised(ls)))
{
return remaining_bytes(p) >= s;
}
return true;
}
/**
* Returns the byte offset into an object.
*