From 16df7b86a1343eb9c028d7859d41f57e30a51822 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 7 Nov 2023 08:50:04 +0100 Subject: [PATCH] sanitizing_allocator: fix zeroing memory when sizeof(T)>1 std::allocator<>::deallocate() second parameter is number of elements, not array size! Signed-off-by: Simon Rozman --- include/WinStd/Common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index cf14e15e..14d5437d 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -1951,11 +1951,11 @@ namespace winstd /// /// Deallocate object at _Ptr sanitizing its content first /// - void deallocate(_In_ pointer _Ptr, _In_ size_type _Size) + void deallocate(_In_ pointer _Ptr, _In_ size_type _Count) { // Sanitize then free. - SecureZeroMemory(_Ptr, _Size); - _Mybase::deallocate(_Ptr, _Size); + SecureZeroMemory(_Ptr, sizeof(_Ty) * _Count); + _Mybase::deallocate(_Ptr, _Count); } };