From d33b571c95379f26c8ca626746cef01ea3b251b9 Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 11 Oct 2022 12:35:01 +1000 Subject: [PATCH] Fix some sanitization warnings. Public issue https://github.com/mackron/miniaudio/issues/550 --- miniaudio.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index 2be77cbd..5a6d4fa1 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -11881,12 +11881,19 @@ Standard Library Stuff #endif #endif -#ifndef MA_ZERO_MEMORY +static MA_INLINE void ma_zero_memory(void* p, size_t sz) +{ #ifdef MA_WIN32 -#define MA_ZERO_MEMORY(p, sz) ZeroMemory((p), (sz)) + ZeroMemory(p, sz); #else -#define MA_ZERO_MEMORY(p, sz) memset((p), 0, (sz)) + if (sz > 0) { + memset(p, 0, sz); + } #endif +} + +#ifndef MA_ZERO_MEMORY +#define MA_ZERO_MEMORY(p, sz) ma_zero_memory((p), (sz)) #endif #ifndef MA_COPY_MEMORY