From 4453a942ceec48be7a06bcebe85d146a6298068a Mon Sep 17 00:00:00 2001 From: Felix Moessbauer Date: Wed, 10 Jul 2019 17:46:21 +0200 Subject: [PATCH] fix: deallocate buffer with correct size --- drace-client/include/aligned-buffer.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drace-client/include/aligned-buffer.h b/drace-client/include/aligned-buffer.h index 71b31a9..3948176 100644 --- a/drace-client/include/aligned-buffer.h +++ b/drace-client/include/aligned-buffer.h @@ -83,9 +83,14 @@ namespace drace { // copy this as value is modified by std::align size_t space_size = _size_in_bytes; _mem = dr_thread_alloc(drcontext, _size_in_bytes); - data = (T*)std::align(alignment, capacity, _mem, space_size); + // std::align changes pointer to memspace, hence copy + void * mem_align = _mem; + DR_ASSERT_MSG( + std::align(alignment, capacity, mem_align, space_size) != nullptr, + "could not allocate aligned memory"); + data = (T*)mem_align; DR_ASSERT(((uint64_t)data % alignment) == 0); } } }; -} \ No newline at end of file +}